Skip to content

Templates

Templates let table rows render through a custom layout instead of the plain front/back columns. They’re perfect for repeated card shapes: vocabulary with furigana, conjugation tables, styled definitions. You write the layout once as a template file, tag your table, and every row is rendered through it.

  1. Pick a folder for templates and set it in Settings → Card templates → Template folder. (Leaving it empty disables templates.)
  2. Create a markdown file in that folder for each layout.
  3. Tag the file (frontmatter tags: or an inline #tag) with the tag you’ll use to bind it.

A template file defines up to six faces using fenced code blocks — an HTML and a markdown version of each of front, back, and notes:

decks-html-front, decks-html-back, decks-html-notes, decks-md-front, decks-md-back, decks-md-notes.

---
tags:
- vocab
---
```decks-html-front
<div class="decks-vocab-card">
<ruby>{{1}}<rt>{{2}}</rt></ruby>
</div>
<style>
.decks-vocab-card { font-size: 2.6em; text-align: center; }
.decks-vocab-card rt { font-size: 0.35em; color: var(--text-muted); }
</style>
```
```decks-md-back
**{{3}}**
```
  • HTML faces render sanitized in an isolated shadow root — <style> is allowed (and can use Obsidian’s theme variables), but <script> is stripped. Your CSS won’t leak into the rest of Obsidian.
  • Markdown faces render through Obsidian’s normal markdown renderer.
  • No code blocks? The file falls back to a single split: everything above the first --- is the front, everything below is the back.

Inside {{…}} you reference the table’s columns:

  • Positional{{1}}, {{2}}, {{3}} (1-based, left to right).
  • By name{{Reading}}, {{Meaning}} (the column header text, case-insensitive).
  • An unknown reference resolves to an empty string.

Show or hide part of a face depending on whether a column has content:

  • {{#Notes}}…{{/Notes}} — kept only when Notes is non-empty.
  • {{^Notes}}…{{/Notes}} — kept only when Notes is empty.

Nesting works — inner sections resolve first.

Templates attach to table rows by tag, best-match wins (the template sharing the most tags):

  1. A tag on the heading above the table, or
  2. A tag in the deck file’s frontmatter.
## Kanji vocabulary #vocab
| Kanji | Reading | Meaning |
| --- | --- | --- |
| 火 | ひ | fire |
| 水 | みず | water |

Here the #vocab on the heading matches the vocab template above, so each row renders as a styled furigana card. A row only uses the template if its front actually references a column that has a value — otherwise it falls back to plain front/back, so a half-filled row never renders blank.