Shortcodes
Shortcodes are reusable HTML components you can call from inside markdown. They're Go templates stored in _shortcodes/.
Creating a shortcode
Create _shortcodes/note.html:
<div role="alert"{{ if .Get "type" }} data-variant="{{ .Get "type" }}"{{ end }}>
{{ .Inner }}
</div>
Using shortcodes
Block shortcodes
Wrap content between opening and closing tags:
{{</* note type="warning" */>}}
This is a **warning** message. Markdown works inside.
{{</* /note */>}}
Result:
This is a warning message. Markdown works inside.
Self-closing shortcodes
For shortcodes without inner content:
{{</* badge text="New" type="success" /*/>}}
Result: New
Shortcode context
Templates receive a ShortcodeContext with:
| Field | Description |
|---|---|
{{ .Inner }} |
Rendered inner content (markdown → HTML) |
{{ .Get "key" }} |
Get a named argument |
{{ .Args }} |
Map of all arguments |
{{ .Page }} |
Parent page's template data |
Examples
Note / alert
_shortcodes/note.html:
<div role="alert"{{ if .Get "type" }} data-variant="{{ .Get "type" }}"{{ end }}>
{{ .Inner }}
</div>
This is an info note. Good for tips and context.
Watch out — this is a warning.
Something went wrong. This is an error alert.
Collapsible details
_shortcodes/details.html:
<details{{ if .Get "open" }} open{{ end }}>
<summary>{{ .Get "summary" }}</summary>
{{ .Inner }}
</details>
Click to expand
This content is hidden by default. Markdown renders here too.
- Item one
- Item two
- Item three
Another section
This one starts open because of open="true".
Processing order
- Parse frontmatter from markdown source
- Find and extract shortcode calls
- Render inner content of block shortcodes as markdown
- Execute shortcode templates with rendered inner + arguments
- Splice shortcode output back into the document
- Render the full document as markdown
This means shortcode output becomes part of the markdown document — you can mix shortcodes and markdown freely.
Syntax reference
Block: {{</* name key="value" */>}}...content...{{</* /name */>}}
Self-closing: {{</* name key="value" /*/>}}
Arguments: key="value" pairs (quoted strings only)