You’re reading the ZotLit v2 docs. Still on v1? Read the v1 docs

ZotLit

Default templates

The built-in Liquid template for each type, with annotations explaining what each line produces.

ZotLit ships a built-in Liquid default for every template. This page shows each default verbatim, explains what it renders, and names the document that holds it once you customize it.

A Profile document carries the note, content, filename, and annotation templates together. The citation text is its own document. Until a document exists, ZotLit renders the built-in text shown below. See Customize a template for how to create one.

Note template

In a Profile document: the note body, above the Annotation Section.

# {{ zt.title }}

[Zotero]({{ zt.backlink }}) {{ zt.attachments | map: "fileLink" | compact | join: " " }}

{% render "content" with zt as zt %}
LineWhat it renders
# {{ zt.title }}Item title as an H1 heading.
[Zotero]({{ zt.backlink }})Markdown link to the item in Zotero (deep link).
{{ zt.attachments | map: "fileLink" | compact | join: " " }}Direct file:// links to every resolvable attachment. For a Zotero linked file, the link points to its original external location. These links do not copy files into the vault. A link to a PDF in your Zotero library opens in Obsidian's PDF reader while Open PDF file links in Obsidian is on, which is the default. map extracts each link, compact drops missing links, and join separates them with a space.
{% render "content" with zt as zt %}Includes the content template, passing the full item context.

Content template

In a Profile document: the end of the note body, written in place. The default has no {% managed %} block.

## Annotations

```zotquery
views:
  - type: annotations
    name: Annotations
    from: annotations
    filters: item == this.item
    sort:
      - property: attachment.dateAdded
        direction: ASC
      - property: sortIndex
        direction: ASC
```

The default body renders once, when ZotLit creates the note. After that it is yours: ZotLit: Update literature note refreshes the frontmatter and leaves the body as written. The default has no Notes list; see Import Zotero notes to bring child notes into the vault.

SectionWhat it renders
AnnotationsA zotquery block that shows the annotations of the note's own item as live cards. this.item is the item that the note's zotero-key property names. The cards sort by attachment, oldest first, then by position in the file.

The annotation cards stay current with Zotero, and you can edit a comment or tags on a card in the note. A change you make in the block's toolbar, such as a new sort, changes the block text. ZotLit: Update literature note keeps the block text that the note holds, so your change stays.

A note that you made with an earlier default lists its annotations as text. When that note still has its managed region, its next update replaces that list with the block.

To list the annotations as text in the note, put the loop below in your own Profile in place of the block. Each annotation renders through the annotation template, and the render_annotation tag passes each annotation as zt. See Annotation rendering for the equivalent native syntax.

{% for annotation in zt.annotations %}
{% render_annotation annotation %}
{% endfor %}

Annotation template

In a Profile document: the Annotation Section, the final section after the standalone line --- zotlit:annotation ---.

{% bq %}
[!note] {% if zt.pageLabel and zt.pageLabel != "" %}Page [{{ zt.pageLabel }}]({{ zt.backlink }}){% else %}[Zotero]({{ zt.backlink }}){% endif %}

{{ zt.imgLink | embed }}{{ zt.text }}{% if zt.citation %} {{ zt.citation }}{% endif %}
{% if zt.comment %}

{{ zt.comment }}
{% endif %}
{% endbq %}

Rendered output for an annotation on page 42 of a paper with the citation key smith2024, with an image excerpt, highlighted text, and a comment:

> [!note] Page [42](zotero://open/library/items/ABCD2345?annotation=ANNX2345&page=42)
>
> ![[excerpt.png]]The highlighted passage [@smith2024, {p. 42}]
>
> My thoughts on this
ElementSource
Callout type[!note]: an Obsidian callout. Change note to quote, info, or any supported type to restyle.
Page labelPage [{{ zt.pageLabel }}]({{ zt.backlink }}) in the callout title: the page label, linked to the annotation's durable Zotero link, zt.backlink. Click it and the PDF opens on this annotation, in Obsidian's reader when this computer holds the PDF. See Zotero open links. An annotation with no page label shows Zotero as the link text.
Image{{ zt.imgLink | embed }}: embeds a prepared image or ink excerpt. A failed refresh keeps a verified previous image, or returns an unavailable-image explanation and source link. Collapses to "" for other annotation types.
Text{{ zt.text }}: the highlighted passage.
Citation{{ zt.citation }}: the paper's citation with this annotation's page as its locator, rendered through the citation text template. Left out for an annotation on a standalone PDF or on a paper with no citation key.
Comment{{ zt.comment }}: the user's marginal note, rendered only when present.

The {% bq %} / {% endbq %} block tag handles the > prefix on every line and collapses consecutive blank lines into a single bare >.

Citation text

In its own document, zotlit-citation.md in the template folder. One template answers both citation gestures, and zt.variant says which one the reader made:

{% if zt.variant == "alt" %}
  {{ zt.citations | pandoc_cite: "prefer-author-in-text" }}
{% else %}
  {{ zt.citations | pandoc_cite }}
{% endif %}

zt.variant is "main" or "alt". "main" comes from Enter in the citation suggester or the insert modal; "alt" comes from Shift+Enter, or from a trailing / in the suggester query. It names the gesture the reader made, and this template decides what each gesture renders. See Citation variant.

The else branch of the built-in default renders a bracketed Citation Cluster, such as [@smith2024, {p. 62}; -@doe2021]. The "alt" branch asks Pandoc for the author-in-text form, which falls back to a bracketed cluster whenever the first retained item carries a prefix or suppresses its author.

Input"main""alt"
One key smith2024[@smith2024]@smith2024
Two keys[@a2020; @b2021]First item in text, the rest in trailing brackets
Locator 62[@smith2024, {p. 62}]@smith2024 [{p. 62}]
suppressAuthor[-@smith2024][-@smith2024], a cluster
Prefix see [see @smith2024][see @smith2024], a cluster
An item with no citation keyDropped from the outputDropped from the output

The pandoc_cite filter behaves the same in both branches:

BehaviorDetail
Prefix and suffixPreserves each item's prefix and suffix.
Suppress authorsuppressAuthor true renders -@key.
LocatorRenders an explicit locator such as , {p. 62} from labelShort and locator.
Complex citation keyAdds braces when Pandoc requires them. For example, KX67D9YM? renders as @{KX67D9YM?}.
Missing citation keyOmits items whose item.citationKey is null. An empty array or all-null array renders nothing.
Formnormal always produces a bracketed Citation Cluster; prefer-author-in-text produces an author-in-text citation only when the first retained item has no prefix and does not suppress its author.

ZotLit normalizes the rendered citation to inline form: leading and trailing whitespace is trimmed, and any whitespace run containing a line break collapses to a single space. This normalization applies everywhere a citation renders: the inline suggester, the command-palette picker, the zt.citation annotation field, Copy citation, and citation resolution during note import.

Only the Liquid edition is built in. The same template in Eta reads:

<% if (zt.variant === "alt") { %>
  <%= pandocCite(zt.citations, "prefer-author-in-text") %>
<% } else { %>
  <%= pandocCite(zt.citations) %>
<% } %>

Filename template

In a Profile document: the filename key of its YAML manifest. The Template Workbench View labels it Note name template.

The rendered output is the name part of a new note's path. ZotLit creates the note in the Profile's literature note folder, under this name.

{{ zt.citationKey | default: zt.DOI | default: zt.title | default: zt.key }}{% suffix %}
ElementDetail
Fallback chaincitationKey > DOI > title > key. The default filter skips nil and empty values.
{% suffix %}Appends a short random string only when the rendered filename collides with an existing note. Absent a collision, it resolves to "".
Single lineThe rendered output is collapsed to a single trimmed line (all newlines and surrounding whitespace removed).
ExtensionThe .md extension is appended automatically; the template produces only the base name.

Subfolders in the note name

A forward slash (/) in the rendered name makes a subfolder under the literature note folder. The folder literatures and the name 2024/Smith2020 give literatures/2024/Smith2020.md.

Live recompilation

Editing a template document in your vault triggers live recompilation through a file watcher. Changes take effect immediately, without reloading the plugin. Moving a document to trash returns its templates to the built-in defaults shown above.

See also

Last updated on

On this page