Basic Replacements
The most basic template looks something like this:Front,
writing {{front}} will not work properly.
Your templates are not limited to a list of fields. You can also include
arbitrary text on your templates. For example, if you’re studying
capital cities, and you’ve created a note type with a “Country” field,
you might create a front template like this:
Newlines
Card templates are like web pages, which means a special command is required to create a new line. For example, if you wrote the following in the template:<br> code to the end of a
line, like so:
Text to Speech for individual fields
This feature requires Anki 2.1.20, AnkiMobile 2.0.56 or AnkiDroid 2.17. To have Anki read the Front field in a US English voice, you can place the following in your card template:- Open the System Preferences screen.
- Click on Accessibility.
- Click on Speech.
- Click on the system voice dropdown, and choose Customize.
cloze-only filter, like so:
Text to Speech for multiple fields and static text
This feature requires Anki 2.1.50+, AnkiMobile 2.0.84+, or AnkiDroid 2.17+. If you want TTS to read multiple fields or static text included in the template, you can use the following:Special Fields
There are some special fields you can include in your templates:{{Tags}} rather than {{tags}} for example.
Hint Fields
It’s possible to add a field to the front or back of a card, but make it hidden until you explicitly show it. We call this a hint field. Before adding a hint, please bear in mind that the easier you make it to answer a question in Anki, the less likely you are to remember that question when you encounter it in real life. Please have a read about the “minimum information principle” on https://super-memory.com/articles/20rules.htm before proceeding. First, you’ll need to add a field to store the hint in if you have not already. Please see the fields section if you’re not sure how to do this. Assuming you’ve created a field called MyField, you can tell Anki to include it on the card but hide it by default by adding the following to your template:{{FrontSide}} from
your back template and manually add the fields you wish to appear.
It is not currently possible to use a hint field for audio — the audio
will play regardless of whether you’ve clicked on the hint link.
If you want to customize the appearance or behaviour, you’ll need to
implement the hint field yourself. We can not provide any support for
doing so, but the following code should get you started:
Dictionary Links
You can also use field replacement to create dictionary links. Imagine you’re studying a language and your favourite online dictionary allows you to search for text using a web URL like:HTML Stripping
Like templates, fields are stored in HTML. In the dictionary link example above, if the expression contained the word “myword” without any formatting, then the HTML would be the same: “myword”. But when you include formatting in your fields, extra HTML is included. If “myword” was bolded for example, the actual HTML would be “myword”. This can present a problem for things like dictionary links. In the above example, the dictionary link would end up being:Right To Left Text
If you’re using a language that reads from right to left, you’ll need to adjust the template like so:Ruby Characters
Some languages commonly use annotations above the text to display the pronunciation of characters. These annotations are known as ruby characters. In Japanese, these are known as furigana. In Anki, you can display ruby characters by using the following syntax:{{Myfield}}, the field will be displayed as is. To properly position the
ruby characters above the text, use the furigana filter in the templates
like so:
| Raw Text | Rendered Text |
|---|---|
Text[Ruby] | |
日本語[にほんご] | |
世[よ]の 中[なか] | |
世[よ]の中[なか] |
Additional Ruby Character Filters
In addition to thefurigana filter, you can also only show certain parts
of the ruby text, with the kana and kanji filters. The kana filter will
only show the ruby text, while the kanji filter removes the ruby text
entirely.
| Raw Text | Field Filter | Rendered Text |
|---|---|---|
日本語[にほんご] | {{furigana:MyField}} | |
日本語[にほんご] | {{kana:MyField}} | にほんご |
日本語[にほんご] | {{kanji:MyField}} | 日本語 |
Media & LaTeX
Anki does not scan templates for media references, because it is slow to do so. This has implications for including media on the template.Static Sounds/Images
If you wish to include images or sounds on your cards that are the same for every card (e.g. a company logo at the top of each card):- Rename the file so it starts with an underscore, e.g “_logo.jpg”. The underscore tells Anki that the file is used by the template and it should be exported when sharing the deck.
- Add a reference to the media on your front or back template, like:
Field References
Media references to fields are not supported. They may or may not display during review, and will not work when checking for unused media, importing/exporting, and so on. Examples that won’t work:Checking Your Answer
You can watch a video about this feature on YouTube. The easiest way to check your answer is to click “Basic” at the top left of the card adding screen, and select “Basic (type in the answer)”. If you have downloaded a shared deck and would like to type in the answer with it, you can modify its card template. If it has a template like:type: in front of the field we want to
compare. Since FrontSide is on the back of the card, the type answer box
will appear on the back as well.
When reviewing, Anki will display a text box where you can type in the
answer, and upon hitting Enter or showing the answer, Anki will show you
which parts you got right and which parts you got wrong. The text box’s
font size will be the size you configured for that field (via the
“Fields” button when editing).
Note that the type answer boxes don’t appear in the preview dialog or in AnkiWeb.
This feature does not change how the cards are answered, so it’s still
up to you to decide how well you remembered or not.
Only one typing comparison can be used on a card. If you add the above
text multiple times, it will not work. It also only supports a single
line, so it is not useful for comparing against a field that is
comprised of multiple lines.
Anki uses a monospaced font for the answer comparison so that the
“provided” and “correct” sections line up. If you wish to override the
font for the answer comparison, you can put the following at the bottom
of your styling section:
!important, like so:
{{type:cloze:Text}} to both the front and back
template, so the back looks something like this:
Ignoring Diacritics
If you don’t want Anki to compare accents on characters in your typed input with the correct answer, you can do so by usingtype:nc in your fields.
بطيخ would be treated the same as بَطِّيخ or elite would be treated same as élite.