Skip to content

Templates

Josh Glazer edited this page Aug 19, 2026 · 3 revisions

Note Templates (Liquid)

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.


Anatomy of a Template

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 }}

Sentinel Header Options

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.

Data Model

Depending on the template name's prefix, different variables are injected:

  • [item]… — Receives item (the first selected item), items (all selected items), and note (the target note, if any).
  • [text]… — Receives note (the target note, if any).
  • All templates receive now (current system date and time).

item Fields

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.

note Fields

Available fields include: note.title, note.tags, note.key, note.parentTitle, note.collections, and note.citekey (inherited from the parent item).


Filters

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.

Authoring in the Template Editor

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.

Built-In (System) Templates

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)

Template Operations

Using a Template

Open a note (or the workspace), click Insert Template in the editor toolbar, and pick a template.

Importing a Template

  1. Copy a template share-code (YAML or JSON).
  2. Go to Tools → New Template from Clipboard in the Zotero menu bar.

Sharing a Template

  1. Open the Note Template Editor (Tools menu).
  2. Select the template in the list.
  3. Click Options → Copy share code.

Migrating Legacy JavaScript Templates

The original arbitrary-JavaScript engine (${ … } script blocks) was deprecated for security. To migrate:

  1. Open the Note Template Editor.
  2. Select your template and go to Options → Convert legacy JavaScript template to Liquid.
  3. Re-verify the converted code; any unsupported JS constructs will be flagged for manual touch-ups.

Clone this wiki locally