What I’m trying to do
I am using a literature note template that is mostly based on a template by lguenth on github to generate literature notes using the Zotero Integration plugin.
I want to preserve the first three call-out boxes (that I call meta-information) and I also want to keep the annotations from being overwritten upon re-importing from Zotero, as I create reading notes that link to specific annotations inside my literature notes, so I don’t want to loose those backlinks. Ideally I would just like to add a new batch of annotations as a sort of appendix to my note, but I have no idea on how to implement this. Any help would be greatly appreciated!
Things I have tried
I have tried to use the ‘persist’ function and use the time stamp to keep the annotations the same. However, when I try to import the note again from Zotero nothing changes, so any new annotations that were made do not show up in the literature note.
---
category: literaturenote
tags:
citekey: "{ citekey }"
status:
- EE
type:
title:
methodology:
contribution:
created: {{importDate|format("YYYY-MM-DD")}}
modified: {{importDate|format("YYYY-MM-DD")}}
---
{% persist "meta information" %}
> [!Cite]
> {{bibliography}}
> [!Success] Key Takeaways
> -
> [!Abstract]
> {%- if abstractNote %}
> {{abstractNote}}
> {%- endif -%}
 
{% endpersist %}
{% persist "annotations" %}
{% if isFirstImport %}
## Annotations
{#- COLOR VARIABLES -#}
{%-
set zoteroColors = {
"#2ea8e5": "blue",
"#5fb236": "green",
"#a28ae5": "purple",
"#ffd400": "yellow",
"#ff6666": "red",
"#f19837": "orange",
"#e56eee": "magenta",
"#aaaaaa": "grey"
}
-%}
{%-
set colorHeading = {
"yellow": "⭐ Main",
"green": "✅ Definition",
"purple": "🧩 Methodology",
"blue": "📚 Further Reading",
"red": "❓Questions",
"magenta": "⚡Debate",
"other": "Misc"
}
-%}
{#- ANNOTATION TYPES -#}
{%- macro calloutHeader(type) -%}
{%- switch type -%}
{%- case "highlight" -%}
Highlight
{%- case "image" -%}
Image
{%- default -%}
Note
{%- endswitch -%}
{%- endmacro %}
{#- SET CUSTOM ANNOTATION COLORS -#}
{%- set newAnnot = [] -%}
{%- set newAnnotations = [] -%}
{%- set annotations = annotations | filterby("date", "dateafter", lastImportDate) %}
{%- for annot in annotations -%}
{%- if annot.color in zoteroColors -%}
{%- set customColor = zoteroColors[annot.color] -%}
{%- elif annot.colorCategory|lower in colorHeading -%}
{%- set customColor = annot.colorCategory|lower -%}
{%- else -%}
{%- set customColor = "other" -%}
{%- endif -%}
{%- set newAnnotations = (newAnnotations.push({"annotation": annot, "customColor": customColor}), newAnnotations) -%}
{%- endfor -%}
{#- INSERT ANNOTATIONS -#}
{#- Loops through each of the available colors and only inserts matching annotations -#}
{#- This is a workaround for inserting categories in a predefined order (instead of using groupby & the order in which they appear in the PDF) -#}
{%- for color, heading in colorHeading -%}
{%- for entry in newAnnotations | filterby ("customColor", "startswith", color) -%}
{%- set annot = entry.annotation -%}
{%- if entry and loop.first %}
### {{colorHeading[color]}}
{%- endif %}
> [!quote{{"|" + color if color != "other"}}]+ {{calloutHeader(annot.type)}} ([p. {{annot.pageLabel}}](zotero://open-pdf/library/items/{{annot.attachment.itemKey}}?page={{annot.pageLabel}}&annotation={{annot.id}}))
{%- if annot.annotatedText %}
> {% if annot.hashTags %}[[{{annot.hashTags|replace("#", "")}}]]: {% endif -%}
{{annot.annotatedText|nl2br}}
{%- endif %}
{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}
{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}
{%- if annot.comment %}
> → **{{annot.comment|nl2br}}**
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
{% endif %}
{% endpersist %}