-
Notifications
You must be signed in to change notification settings - Fork 0
Templates
Enhanced Notes templates let you generate note content (and exported filenames/contents) dynamically from your Zotero items. Templates are written in a sandboxed Liquid language (using LiquidJS), which replaces the legacy arbitrary-JavaScript template engine for safety and simplicity.
A Liquid template is a Markdown or HTML document containing values ({{ ... }}) and logic ({% ... %}), preceded by an optional sentinel header:
<!--liquid-->
<!--markdown-->
<!--addTags: ItemNote-->
# {{ item.citekey }}
- Title: {{ item.title }}
- Year: {{ item.year }}
- Authors:
{% for a in item.authors %} - {{ a.name }}
{% endfor %}- Abstract: {{ item.abstract | oneline }}The sentinel header must be placed at the very beginning of the template and is stripped out before rendering:
| Sentinel | Effect |
|---|---|
<!--liquid--> |
Required. Marks the template as Liquid (rather than legacy JavaScript). |
<!--markdown--> |
The rendered output is treated as Markdown and automatically converted to note HTML. |
<!--addTags: A, B--> |
Once rendered, adds the tags A and B to the target note. |
Depending on the template name's prefix, different variables are injected:
-
[item]…— Receivesitem(the first selected item),items(all selected items), andnote(the target note, if any). -
[text]…— Receivesnote(the target note, if any). - All templates receive
now(current system date and time).
| Field | Description |
|---|---|
item.title |
The item's title. |
item.authors / item.creators
|
Array of creators: { firstName, lastName, name } (where name is "Last, First"). |
item.date |
Raw date string. |
item.year |
4-digit year extracted from the date. |
item.tags |
Array of tag strings. |
item.abstract |
Abstract content. |
item.citekey |
Better BibTeX key → extra "Citation Key:" → native citationKey. |
item.collections |
Array of collection names the item belongs to. |
item.doi, item.url, item.itemType, item.key
|
Metadata identifiers. |
Available fields include: note.title, note.tags, note.key, note.parentTitle, note.collections, and note.citekey (inherited from the parent item).
In addition to standard LiquidJS built-in filters (like join, upcase, truncate, and date), Enhanced Notes provides several custom filters:
| Filter | Effect |
|---|---|
year |
Extracts a 4-digit year from a date string. |
sanitize_filename |
Replaces filename-illegal characters and spaces with hyphens -. |
oneline |
Collapses newline runs to a single space (ideal for abstracts). |
md |
Renders a Markdown string to note HTML. |
The Template Editor has a live preview plus two aids that share one catalog (so they never drift):
-
Autocomplete — type-ahead for variables, fields, filters, and tags as you type inside
{{ … }}/{% … %}(Ctrl-Space to trigger). - Click-to-insert palette — a grouped panel below the editor (Syntax / Variables / Item fields / Note fields / Filters / Tags) whose buttons insert ready-to-use Liquid at the cursor; hover a button for its description.
Enhanced Notes uses reserved template names to run automatically at specific times. You can open and edit these in the Template Editor, and your edits persist across restarts (e.g. customize your export filename format). Their names are reserved (you can't rename or delete a system template), and Options → Reset restores the shipped default at any time:
| Template | Triggered When... | Context Received | Output |
|---|---|---|---|
[QuickInsertV3] |
Inserting a link to another note |
link, linkText, lineIndex, sectionName, selectionText, note, now
|
Markdown link |
[QuickImportV2] |
Embedding a linked note's content |
link, linkContent (rendered HTML), note, now
|
HTML blockquote |
[QuickNoteV5] |
Creating a note from a single annotation |
commentHTML, annotation via {% annotations %}, note, now
|
HTML |
[ExportMDFileNameV2] |
Exporting/syncing a note to a .md file |
note, now
|
Bare filename (e.g. smith2020.md) |
[ExportMDFileContent] |
Writing the body of an exported .md file |
mdContent (Markdown body) |
Raw Markdown (passthrough) |
[ExportLatexFileContent] |
Exporting a note to LaTeX |
latexContent (LaTeX body) |
Raw LaTeX (passthrough) |
Open a note (or the workspace), click Insert Template in the editor toolbar, and pick a template.
- Copy a template share-code (YAML or JSON).
- Go to Tools → New Template from Clipboard in the Zotero menu bar.
- Open the Note Template Editor (Tools menu).
- Select the template in the list.
- Click Options → Copy share code.
The original arbitrary-JavaScript engine (${ … } script blocks) was deprecated for security. To migrate:
- Open the Note Template Editor.
- Select your template and go to Options → Convert legacy JavaScript template to Liquid.
- Re-verify the converted code; any unsupported JS constructs will be flagged for manual touch-ups.