Shortcodes
Shortcodes let you embed rich, structured content in markdown without writing raw HTML. They bridge the gap between markdown’s simplicity and the flexibility of full templates.
Syntax #
Inline shortcodes (no body) use double curly braces:
{{ figure(src="/images/photo.jpg", alt="A photo", caption="My caption") }}
Body shortcodes (wrap content) use curly-percent:
{% note(type="warning") %}
Be careful with this operation.
{% end %}
Built-in shortcodes #
| Shortcode | Type | Description |
|---|---|---|
include | Inline | Include another file’s content |
tabs | Body | Tabbed content panels |
note | Body | Styled callout box |
details | Body | Collapsible <details> section |
figure | Inline | Image with optional caption |
youtube | Inline | Embedded YouTube video |
gist | Inline | Embedded GitHub gist |
mermaid | Body | Mermaid.js diagram |
pyref | Inline | Python API reference (requires python feature) |
configref | Inline | Config reference from Rust source doc comments |
flow | Inline | Horizontal step flow diagram |
layers | Inline | Vertical layered stack diagram |
tree | Body | File tree visualization |
compare | Inline | Side-by-side comparison cards |
cascade | Inline | Priority/override cascade diagram |
slide_image | Inline | Absolutely positioned image (presentations) |
speaker_notes | Body | Reveal.js speaker notes (presentations) |
fragment | Body | Progressive reveal on click (presentations) |
columns | Body | Multi-column layout (presentations) |
The diagram shortcodes (flow, layers, tree, compare, cascade) render pure CSS/HTML visuals with no JavaScript. They are used throughout these docs — see content model and AI-native for examples.
The presentation shortcodes (slide_image, speaker_notes, fragment, columns) are designed for use in presentations but work in any page.
See the shortcodes reference for parameters and live examples.
Custom shortcodes #
Create a template in templates/shortcodes/ to define your own:
<!-- templates/shortcodes/greeting.html --> <p class="greeting">Hello, {{ name }}!</p>
Use it in markdown:
{{ greeting(name="world") }}
Body shortcodes receive the inner content as body:
<!-- templates/shortcodes/card.html --> <div class="card"> <h3>{{ title }}</h3> {{ body }} </div>
{% card(title="My card") %}
Card content goes here.
{% end %}
Shortcodes vs. callouts vs. templates #
| Tool | Best for |
|---|---|
| Callouts | Inline alerts in prose (note, warning, tip) |
| Shortcodes | Reusable rich components (figures, tabs, embeds) |
| Templates | Full page layouts and structural HTML |
Further reading #
- Shortcodes reference — all 19 built-in shortcodes with live examples
- Callouts — GitHub-style alert boxes
- Templates — the Tera template engine
- How to customize your theme — create custom shortcodes