Future support for external templates (HTML/Text/JavaScript), in addition to CSS, in Anki?
Currently, it’s already possible to use external files for styling cards by importing CSS like this:
@import url("_0ankiflashcards.css");
.card {
background: #FFFFFF;
}
This makes visual editing much easier, especially when using a proper IDE or code editor instead of relying only on Anki’s internal editor.
My question is:
Would it be possible in the future to have a similar approach for the front and back templates (HTML, text, or even JavaScript), making them external and editable directly via an IDE?
This is not something I expect right now, but I’m thinking long-term, in case Anki ever migrates to a more external/template-based model.
Some of the benefits would include:
- Easier and more professional editing of card layouts.
- Better version control (Git) and easier sharing of templates.
- Improved organization, especially for users who create more complex decks.
- More control over the code, beyond the limitations of the internal editor.
I came across a forum post that suggests something very similar, but it seems nobody has commented on it:
Store card template files as HTML and CSS in external folder
"I would like to suggest that card templates and the styling info be stored as .html and .css in a folder in the user profile directory that is accessible from the file system.
Reasons why this is a good idea:
• Making complex card types with lots of JavaScript will be much easier
• Easy to access and backup
• Easy editing with external editors, without needing add-ons or AnkiConnect
• Version control with Git
Maybe something else that would need to be added is a ‘refresh’ button in the card template editor, for if you have made external changes to the files and want to see them immediately in the card template editor preview pane. This would make debugging a little easier (especially when combined with the add-on that gives access to Chrome developer tools in Anki)."
I also found another related discussion:
Putting Anki code in an external file
The user there expresses a similar need — the desire to avoid repeating the same block of HTML/CSS/field references on multiple cards, and instead reference an external file. They mention:
“Sometimes this ‘code’ needs to be changed or expanded. I can do that using a mass replace for all cards containing it, but that’s a bit dangerous. What if I get it wrong? I could create quite a mess. So, what I would prefer to do is to be able to refer in each card of this type to an external file containing the ‘code’, which is the same for each card of the type, and then modify the ‘code’ in that file as needed.”
It was clarified there that while CSS and JavaScript can be placed in an external file, field references still need to be placed directly in the template.
Still, I wonder if there is any plan, discussion, or technical feasibility for expanding external file support to include not only CSS/JS but also the card templates themselves (HTML with field references).
Thanks in advance for any insights or thoughts on this topic!