Zotero Integration – Import Templates?

Hi everyone, thank you for all the templates in this thread!

I’ve been setting up an Obsidian-Zotero workflow so have been messing around with some of the templates to find something that would work well for me, and I thought I’d share it here as well.

I used this template by Marshall_Tang as a base. In most of the templates that I have seen so far, it looks like there’s an issue when reimporting annotations such that the headings would be created again while being appended to the older text that’s within a persist block. I’ve found a workaround that allows for the new annotations to be appended to its corresponding group below the annotations from the previous import without creating a duplicate heading. I’ve also made it so that if there are no annotations of a particular colour (e.g., Red), then its corresponding heading will not be created during the first import, but if there’s a red annotation in the second import, the heading will be created and the annotation will be placed in the correct group. It also preserves the order of the groups/colours/headings through all imports.

@headswillroll1789 @Feralflora When searching about this issue, I came across this forum post where you were discussing the duplicated headings. I’m not sure if anyone else has shared any template with a workaround, but if not, maybe this could be of use. It was a bit tricky to do considering how the persistent field function works but it seems to be working for me so far. I broke the persist blocks into smaller chunks for each group and used the import dates as a reference to avoid the duplicate headings. If anyone has any suggestions to make the template better, I’d love to hear them!

I’ve shared the template below along with a couple of screenshots. The css snippet I’m using is from Iguenth available in their obsidian-templates repository on GitHub.


---
title: "{{title | escape}}"
authors: {{authors}}
year: {{date | format("YYYY")}}
type: {{itemType}}
journal: {{publicationTitle}}
doi: {{DOI}}
tags: {% if allTags %}{{allTags}}{% endif %}
citekey: {{citekey}}
date added: {{exportDate | format("DD/MM/YYYY")}}
cssclass: literature-note
---

# {{title}}


> [!abstract]- 
> {% if abstractNote %} 
> {{abstractNote|replace("\n"," ")}}
> {% endif %}


> [!info]- Metadata – {% for attachment in attachments | filterby("path", "endswith", ".pdf") %}[PDF{% if not loop.first %} {{loop.index}}{% endif %}]({{attachment.desktopURI|replace("/select/", "/open-pdf/")}}){% if not loop.last %}, {% endif %}{% endfor %}
> **Title**:: {{title}}  
> **Authors**:: {%- for creator in creators %} {%- if creator.name == null %} {{creator.firstName}} {{creator.lastName}}, {%- endif -%} {%- if creator.name %}**{{creator.creatorType | capitalize}}**:: {{creator.name}}{%- endif -%}{%- endfor %}
> **Year**:: {{date | format("YYYY")}} 
> {%- if itemType %}**ItemType**:: {{itemType}}{%- endif %}  
> {%- if itemType == "journalArticle" %}**Journal**:: *{{publicationTitle}}* {%- endif %} {%- if itemType == "bookSection" %}**Book**:: {{publicationTitle}} {%- endif %}
> {% if hashTags %}**Keywords**:: {{hashTags}}{% endif %}
> {%- if DOI %}**DOI**:: {{DOI}}{% endif %}{%- if ISBN %}
> **ISBN**:: {{ISBN}}{% endif %}
> **Related**:: {% for relation in relations -%} {%- if relation.citekey -%} [[{{relation.citekey}}]], {% endif -%} {%- endfor%}

{% persist "notes" %}
{%- if isFirstImport %}

> [!Tldr]- Key Takeaways
> **Research Gap/Qs**: 
> **Methodology**:
> **Result**:
> **Contribution**:
> **Limitation**:

{% endif -%}
{%- endpersist %}

## Reading Notes

{%- macro calloutHeader(type) -%}
    {%- switch type -%}
        {%- case "highlight" -%}
        Highlight
        {%- case "image" -%}
        Figure
        {%- default -%}
        Note
    {%- endswitch -%}
{%- endmacro -%}

{%- set annotAll = [] -%}
{%- set annotAll= annotations | filterby("date", "dateafter", lastImportDate) -%}

{% if annotations.length > 0 %}

*Imported: {{importDate | format("DD/MM/YYYY HH:mm")}}*

{%- set annotOld = [] -%}
{%- set annotOld = annotations | filterby("date", "dateonorbefore", lastImportDate) -%}

{################# Red Annotations #################}

{%- set annotRed = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Red" -%}
		{%- set annotRed = (annotRed.push(a), annotRed) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotRedOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Red" -%}
		{%- set annotRedOld = (annotRedOld.push(a), annotRedOld) -%}
	{%- endif -%}
{%- endfor -%}


{%- persist "rednotes" -%}

{### Inserts a heading only if there are red annotations in the current import and if there weren't any in previous imports ###}
{%- if annotRed.length > 0 -%}
	{% if annotRedOld.length <= 0 %}
### Disagree with / Sceptical of Author
	{%- endif -%}
{% endif %}

{% if annotRed.length > 0 %}
{%- for annot in annotRed -%}

> [!quote|red]+ {{ calloutHeader(annot.type) }} ([Page {{ annot.pageLabel }}]({{ annot.desktopURI }}))

{%- if annot.annotatedText %}
> {{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}

{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
> - **{{annot.comment|nl2br}}**
{%- endif %}

{% endfor %}
{%- endif %}
{%- endpersist -%}

{############## Yellow Annotations ##############}

{%- set annotYellow = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Yellow" -%}
		{%- set annotYellow = (annotYellow.push(a), annotYellow) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotYellowOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Yellow" -%}
		{%- set annotYellowOld = (annotYellowOld.push(a), annotYellowOld) -%}
	{%- endif -%}
{%- endfor -%}

{%- persist "yellownotes" -%}
{%- if annotYellow.length > 0 -%}
	{% if annotYellowOld.length <= 0 %}
### Important / Interesting Point by Author
	{%- endif -%}
{% endif %}

{% if annotYellow.length > 0 %}
{%- for annot in annotYellow -%}

> [!quote|yellow]+ {{ calloutHeader(annot.type) }} ([Page {{ annot.pageLabel }}]({{ annot.desktopURI }}))

{%- if annot.annotatedText %}
> {{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}

{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
> - **{{annot.comment|nl2br}}**
{%- endif %}

{% endfor %}
{%- endif %}
{%- endpersist -%}

{############## Green Annotations ##############}

{%- set annotGreen = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Green" -%}
		{%- set annotGreen = (annotGreen.push(a), annotGreen) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotGreenOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Green" -%}
		{%- set annotGreenOld = (annotGreenOld.push(a), annotGreenOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "greennotes" %}
{%- if annotGreen.length > 0 -%}
	{% if annotGreenOld.length <= 0 %}
### Very Important
	{%- endif -%}
{% endif %}

{% if annotGreen.length > 0 %}
{%- for annot in annotGreen -%}

> [!quote|green]+ {{ calloutHeader(annot.type) }} ([Page {{ annot.pageLabel }}]({{ annot.desktopURI }}))

{%- if annot.annotatedText %}
> {{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}

{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
> - **{{annot.comment|nl2br}}**
{%- endif %}

{% endfor %}
{%- endif %}
{%- endpersist -%}

{############### Grey Annotations ################}

{%- set annotGrey = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Gray" -%}
		{%- set annotGrey = (annotGrey.push(a), annotGrey) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotGreyOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Grey" -%}
		{%- set annotGreyOld = (annotGreyOld.push(a), annotGreyOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "greynotes" %}
{%- if annotGrey.length > 0 -%}
	{% if annotGreyOld.length <= 0 %}
### Methodology
	{%- endif -%}
{% endif %}

{% if annotGrey.length > 0 %}
{%- for annot in annotGrey -%}

> [!quote|grey]+ {{ calloutHeader(annot.type) }} ([Page {{ annot.pageLabel }}]({{ annot.desktopURI }}))

{%- if annot.annotatedText %}
> {{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}

{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
> - **{{annot.comment|nl2br}}**
{%- endif %}

{% endfor %}
{%- endif %}
{%- endpersist -%}

{############### Purple Annotations ################}

{%- set annotPurple = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Purple" -%}
		{%- set annotPurple = (annotPurple.push(a), annotPurple) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotPurpleOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Purple" -%}
		{%- set annotPurpleOld = (annotPurpleOld.push(a), annotPurpleOld) -%}
	{%- endif -%}
{%- endfor -%}

{%- persist "purplenotes" -%}
{%- if annotPurple.length > 0 -%}
	{%- if annotPurpleOld.length <= 0 %}
### Confused / Have Further Questions
	{%- endif -%}
{% endif %}

{% if annotPurple.length > 0 %}
{%- for annot in annotPurple -%}

> [!quote|purple]+ {{ calloutHeader(annot.type) }} ([Page {{ annot.pageLabel }}]({{ annot.desktopURI }}))

{%- if annot.annotatedText %}
> {{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}

{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
> - **{{annot.comment|nl2br}}**
{%- endif %}

{% endfor %}
{%- endif %}
{%- endpersist -%}

{############### Blue Annotations ################}

{%- set annotBlue = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Blue" -%}
		{%- set annotBlue = (annotBlue.push(a), annotBlue) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotBlueOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Blue" -%}
		{%- set annotBlueOld = (annotBlueOld.push(a), annotBlueOld) -%}
	{%- endif -%}
{%- endfor -%}

{%- persist "bluenotes" -%}
{%- if annotBlue.length > 0 -%}
	{% if annotBlueOld.length <= 0 %}
### Interesting References / Connected to the Larger Research Question
	{%- endif -%}
{% endif %}

{% if annotBlue.length > 0 %}
{%- for annot in annotBlue -%}

> [!quote|blue]+ {{ calloutHeader(annot.type) }} ([Page {{ annot.pageLabel }}]({{ annot.desktopURI }}))

{%- if annot.annotatedText %}
> {{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}

{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
> - **{{annot.comment|nl2br}}**
{%- endif %}

{% endfor %}
{%- endif %}
{%- endpersist -%}

{############### Orange Annotations ################}

{%- set annotOrange = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Orange" -%}
		{%- set annotOrange = (annotOrange.push(a), annotOrange) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotOrangeOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Orange" -%}
		{%- set annotOrangeOld = (annotOrangeOld.push(a), annotOrangeOld) -%}
	{%- endif -%}
{%- endfor -%}

{%- persist "orangenotes" -%}
{%- if annotOrange.length > 0 -%}
	{% if annotOrangeOld.length <= 0 %}
### Definitions / Sources for Literature Review
	{%- endif -%}
{% endif %}

{% if annotOrange.length > 0 %}
{%- for annot in annotOrange -%}

> [!quote|orange]+ {{ calloutHeader(annot.type) }} ([Page {{ annot.pageLabel }}]({{ annot.desktopURI }}))

{%- if annot.annotatedText %}
> {{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}

{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
> - **{{annot.comment|nl2br}}**
{%- endif %}

{% endfor %}
{%- endif %}
{%- endpersist -%}

{############### Magenta Annotations ################}

{%- set annotPink = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Magenta" -%}
		{%- set annotPink = (annotPink.push(a), annotPink) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotPinkOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Magenta" -%}
		{%- set annotPinkOld = (annotPinkOld.push(a), annotPinkOld) -%}
	{%- endif -%}
{%- endfor -%}

{%- persist "pinknotes" -%}
{%- if annotPink.length > 0 -%}
	{% if annotPinkOld.length <= 0 %}
### Miscellaneous
	{%- endif -%}
{% endif %}

{% if annotPink.length > 0 %}
{%- for annot in annotPink -%}

> [!quote|pink]+ {{ calloutHeader(annot.type) }} ([Page {{ annot.pageLabel }}]({{ annot.desktopURI }}))

{%- if annot.annotatedText %}
> {{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}

{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
> - **{{annot.comment|nl2br}}**
{%- endif %}

{% endfor %}
{%- endif %}
{%- endpersist -%}
{%- endif -%}
2 Likes

Adding on to my previous post, I’ve streamlined the template a bit more to avoid repetition. The code to render the headings and annotations are now in macros. The order in which the colours are sorted can be freely changed by moving the specific annotation groups. I was also thinking of adding some Dataview elements but the new Bases feature seems quite good, so I’m hoping it will be available outside early access soon!

---
title: "{{title | escape}}"
authors: {{authors}}
year: {{date | format("YYYY")}}
type: {{itemType}}
journal: {{publicationTitle}}
doi: {{DOI}}
tags: {% if allTags %}{{allTags}}{% endif %}
citekey: {{citekey}}
date added: {{exportDate | format("DD/MM/YYYY")}}
cssclass: literature-note
---

# {{title}}


> [!abstract]- 
> {% if abstractNote %} 
> {{abstractNote|replace("\n"," ")}}
> {% endif %}


> [!info]- Metadata – {% for attachment in attachments | filterby("path", "endswith", ".pdf") %}[PDF{% if not loop.first %} {{loop.index}}{% endif %}]({{attachment.desktopURI|replace("/select/", "/open-pdf/")}}){% if not loop.last %}, {% endif %}{% endfor %}
> **Title**:: {{title}}  
> **Authors**:: {%- for creator in creators %} {%- if creator.name == null %} {{creator.firstName}} {{creator.lastName}}, {%- endif -%} {%- if creator.name %}**{{creator.creatorType | capitalize}}**:: {{creator.name}}{%- endif -%}{%- endfor %}
> **Year**:: {{date | format("YYYY")}} 
> {%- if itemType %}**ItemType**:: {{itemType}}{%- endif %}  
> {%- if itemType == "journalArticle" %}**Journal**:: *{{publicationTitle}}* {%- endif %} {%- if itemType == "bookSection" %}**Book**:: {{publicationTitle}} {%- endif %}
> {% if hashTags %}**Keywords**:: {{hashTags}}{% endif %}
> {%- if DOI %}**DOI**:: {{DOI}}{% endif %}{%- if ISBN %}
> **ISBN**:: {{ISBN}}{% endif %}
> **Related**:: {% for relation in relations -%} {%- if relation.citekey -%} [[{{relation.citekey}}]], {% endif -%} {%- endfor%}

{% persist "notes" %}
{%- if isFirstImport %}

> [!Tldr]- Key Takeaways
> **Research Gap/Qs**: 
> **Methodology**:
> **Result**:
> **Contribution**:
> **Limitation**:

{% endif -%}
{%- endpersist %}

## Reading Notes

{%- macro renderHeading(newArr, oldArr, headingText) -%}
	{### Only print the heading on a *first* import of this colour ###}
	{%- if newArr.length > 0 and oldArr.length <= 0 %}
### {{ headingText }}
	{% endif %}
{%- endmacro -%}

{%- macro calloutHeader(type) -%}
    {%- switch type -%}
        {%- case "highlight" -%}
        Highlight
        {%- case "image" -%}
        Figure
        {%- default -%}
        Note
    {%- endswitch -%}
{%- endmacro -%}

{%- macro renderCallout(annot, color) %}
> [!quote{{"|" + color}}]+ {{ calloutHeader(annot.type) }} ([Page {{ annot.pageLabel }}]({{ annot.desktopURI }}))

{%- if annot.annotatedText %}
> {{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}

{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
> - **{{annot.comment|nl2br}}**
{%- endif %}
{% endmacro %}

{%- set annotAll = [] -%}
{%- set annotAll= annotations | filterby("date", "dateafter", lastImportDate) -%}

{% if annotations.length > 0 %}

*Imported: {{importDate | format("DD/MM/YYYY HH:mm")}}*

{%- set annotOld = [] -%}
{%- set annotOld = annotations | filterby("date", "dateonorbefore", lastImportDate) -%}

{################# Red Annotations #################}

{%- set annotRed = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Red" -%}
		{%- set annotRed = (annotRed.push(a), annotRed) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotRedOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Red" -%}
		{%- set annotRedOld = (annotRedOld.push(a), annotRedOld) -%}
	{%- endif -%}
{%- endfor -%}

{%- persist "rednotes" -%}

{{ renderHeading(annotRed, annotRedOld, "Disagree with / Sceptical of Author")}}

{%- if annotRed.length > 0 %}
	{%- for annot in annotRed -%}
		{{ renderCallout(annot, "red")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############## Yellow Annotations ##############}

{%- set annotYellow = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Yellow" -%}
		{%- set annotYellow = (annotYellow.push(a), annotYellow) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotYellowOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Yellow" -%}
		{%- set annotYellowOld = (annotYellowOld.push(a), annotYellowOld) -%}
	{%- endif -%}
{%- endfor -%}

{%- persist "yellownotes" -%}

{{ renderHeading(annotYellow, annotYellowOld, "Important / Interesting Point by Author")}}

{%- if annotYellow.length > 0 %}
	{%- for annot in annotYellow -%}
		{{ renderCallout(annot, "yellow")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############## Green Annotations ##############}

{%- set annotGreen = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Green" -%}
		{%- set annotGreen = (annotGreen.push(a), annotGreen) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotGreenOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Green" -%}
		{%- set annotGreenOld = (annotGreenOld.push(a), annotGreenOld) -%}
	{%- endif -%}
{%- endfor -%}

{%- persist "greennotes" -%}

{{ renderHeading(annotGreen, annotGreenOld, "Very Important")}}

{%- if annotGreen.length > 0 %}
	{%- for annot in annotGreen -%}
		{{ renderCallout(annot, "green")}}
	{%- endfor %}
{%- endif %}
{% endpersist -%}

{############### Grey Annotations ################}

{%- set annotGrey = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Gray" -%}
		{%- set annotGrey = (annotGrey.push(a), annotGrey) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotGreyOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Grey" -%}
		{%- set annotGreyOld = (annotGreyOld.push(a), annotGreyOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "greynotes" -%}

{{ renderHeading(annotGrey, annotGreyOld, "Methodology")}}

{%- if annotGrey.length > 0 %}
	{%- for annot in annotGrey -%}
		{{ renderCallout(annot, "grey")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Purple Annotations ################}

{%- set annotPurple = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Purple" -%}
		{%- set annotPurple = (annotPurple.push(a), annotPurple) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotPurpleOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Purple" -%}
		{%- set annotPurpleOld = (annotPurpleOld.push(a), annotPurpleOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "purplenotes" -%}

{{ renderHeading(annotPurple, annotPurpleOld, "Confused / Have Further Questions")}}

{%- if annotPurple.length > 0 %}
	{%- for annot in annotPurple -%}
		{{ renderCallout(annot, "purple")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Blue Annotations ################}

{%- set annotBlue = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Blue" -%}
		{%- set annotBlue = (annotBlue.push(a), annotBlue) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotBlueOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Blue" -%}
		{%- set annotBlueOld = (annotBlueOld.push(a), annotBlueOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "bluenotes" -%}

{{ renderHeading(annotBlue, annotBlueOld, "Interesting References / Connected to the Larger Research Question")}}

{%- if annotBlue.length > 0 %}
	{%- for annot in annotBlue -%}
		{{ renderCallout(annot, "blue")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Orange Annotations ################}

{%- set annotOrange = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Orange" -%}
		{%- set annotOrange = (annotOrange.push(a), annotOrange) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotOrangeOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Orange" -%}
		{%- set annotOrangeOld = (annotOrangeOld.push(a), annotOrangeOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "orangenotes" -%}

{{ renderHeading(annotOrange, annotOrangeOld, "Definitions / Sources for Literature Review")}}

{%- if annotOrange.length > 0 %}
	{%- for annot in annotOrange -%}
		{{ renderCallout(annot, "orange")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Pink (Magenta in Zotero) Annotations ################}

{%- set annotPink = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Magenta" -%}
		{%- set annotPink = (annotPink.push(a), annotPink) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotPinkOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Magenta" -%}
		{%- set annotPinkOld = (annotPinkOld.push(a), annotPinkOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "pinknotes" -%}

{{ renderHeading(annotPink, annotPinkOld, "Miscellaneous")}}

{%- if annotPink.length > 0 %}
	{%- for annot in annotPink -%}
		{{ renderCallout(annot, "pink")}}
	{%- endfor -%}
{%- endif %}
{% endpersist %}
{%- endif -%}

2 Likes

@Feralflora

Thank you for providing these tools as well as your time/energy in supporting folks, like myself, who run into issues.

  1. I can successfully import new literature notes
  2. I cannot, per the meta bind button, update these notes. I receive the following error (below). I am hoping you can help me.

Updated plugins

All applicable Zotero/Obsidian plugins are up-to-date.

Zotero App - Citekey verification
The citekey matches Zotero

Zotero Integration
The Import Name is “litnote”
The template file for the layout is selected correctly
Filepath off the template/layout:

Sources and info/Resources/Obsidian/Templates/ZI-main-3.5-BAM.md

Templater
Runimport is set up as a Template hotkey

Hotkeys are set up

Meta Bind Button
Copy/pasted button template:

label: Update literature note
hidden: false
tooltip: This will fetch new annotations from Zotero
id: update-litnote
style: primary
actions:

  • type: command
    command: templater-obsidian:Sources and info/Resources/Obsidian/Templates/runImport.md

RunImport

Filepath of the runimport file:
Sources and info/Resources/Obsidian/Templates/runImport.md

Updated to “litnote” important name

2 Likes

I think this could be what I’m looking for but following the instructions on github is yielding errors. I’m using the latest template have setup meta bind, hot key, etc when I try and update it creates a new Untitled note. “Error retrieving item data: not found Untitled #” . I appreciate any guidance I see reference to List elements but thats from 2023 and doesn’t seem to be on the github page.

Hi @bam24, Did you find a solution to this? It looks like I’m seeing the same issue (see below).

I have not!

@Feralflora Would be great if you have any sense of what the problem is. Looks like a couple of us are hitting the same issue. Thanks!

Could you please tell me how things are currently with importing highlights if the original book is in ePub format? Are there any working solutions?

I love the template. However, I found that some of my tags in Zotero have spaces in the name. This mucks up the YAML in Obsidian.

I have this fix, which replaces all the spaces in tag names with hyphens.

replace the tags line in your YAML with this
tags: [{% if allTags %}{% for tag in allTags.split(",") %}{{ tag | trim | replace(" ", "-") }}{% if not loop.last %}, {% endif %}{% endfor %}{% endif %}]

I have also put in the square brackets, so that it works as an array, as Obsidian now mandates.

1 Like

Thank you very much for sharing this! I can’t edit my original template post here but if anyone else would like to use it, please change the tags in the yaml section to this.

1 Like

Hello all,

Thanks for sharing this terrific resource.

However, I cannot seem to get my zotero integration templates to work with the integration plugin.

I’m using the latest version of Zotero and BetterBibTex (I un- and then re-installed the BBT plugin to make sure of that).

I’ll copy the template I’m using below.

The error I get is that no note with annotations is created. I can trigger the integration plugin, and it asks me to input the Zotero reference. I do that, and click enter, and nothing happens.

I launched the “Zotero Data Explorer” in Obsidian, and ran the process again, and the error it displays is “No data retrieved.”

I’ve gone over the instructions shared here, and on many linked resources, and am still scratching my head as to what I’m doing wrong.

Any help would be much appreciated!



title: “{{title | escape}}”
authors: {{authors}}
year: {{date | format(“YYYY”)}}
type: {{itemType}}
journal: {{publicationTitle}}
doi: {{DOI}}
tags: {% if allTags %}{{allTags}}{% endif %}
citekey: {{citekey}}
date added: {{exportDate | format(“DD/MM/YYYY”)}}
cssclass: literature-note

{{title}}

[!abstract]-
{% if abstractNote %}
{{abstractNote|replace(“\n”," ")}}
{% endif %}

[!info]- Metadata – {% for attachment in attachments | filterby(“path”, “endswith”, “.pdf”) %}[PDF{% if not loop.first %} {{loop.index}}{% endif %}]({{attachment.desktopURI|replace(“/select/”, “/open-pdf/”)}}){% if not loop.last %}, {% endif %}{% endfor %}
Title:: {{title}}
Authors:: {%- for creator in creators %} {%- if creator.name == null %} {{creator.firstName}} {{creator.lastName}}, {%- endif -%} {%- if creator.name %}{{creator.creatorType | capitalize}}:: {{creator.name}}{%- endif -%}{%- endfor %}
Year:: {{date | format(“YYYY”)}}
{%- if itemType %}ItemType:: {{itemType}}{%- endif %}
{%- if itemType == “journalArticle” %}Journal:: {{publicationTitle}} {%- endif %} {%- if itemType == “bookSection” %}Book:: {{publicationTitle}} {%- endif %}
{% if hashTags %}Keywords:: {{hashTags}}{% endif %}
{%- if DOI %}DOI:: {{DOI}}{% endif %}{%- if ISBN %}
ISBN:: {{ISBN}}{% endif %}
Related:: {% for relation in relations -%} {%- if relation.citekey -%} [[{{relation.citekey}}]], {% endif -%} {%- endfor%}

{% persist “notes” %}
{%- if isFirstImport %}

[!Tldr]- Key Takeaways
Research Gap/Qs:
Methodology:
Result:
Contribution:
Limitation:

{% endif -%}
{%- endpersist %}

Reading Notes

{%- macro renderHeading(newArr, oldArr, headingText) -%}
{### Only print the heading on a first import of this colour ###}
{%- if newArr.length > 0 and oldArr.length <= 0 %}

{{ headingText }}

{% endif %}

{%- endmacro -%}

{%- macro calloutHeader(type) -%}
{%- switch type -%}
{%- case “highlight” -%}
Highlight
{%- case “image” -%}
Figure
{%- default -%}
Note
{%- endswitch -%}
{%- endmacro -%}

{%- macro renderCallout(annot, color) %}

[!quote{{“|” + color}}]+ {{ calloutHeader(annot.type) }} ([Page {{ annot.pageLabel }}]({{ annot.desktopURI }}))

{%- if annot.annotatedText %}

{{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.imageRelativePath %}

![[{{annot.imageRelativePath}}]]
{%- endif %}

{%- if annot.ocrText %}

{{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}

  • {{annot.comment|nl2br}}
    {%- endif %}
    {% endmacro %}

{%- set annotAll = -%}
{%- set annotAll= annotations | filterby(“date”, “dateafter”, lastImportDate) -%}

{% if annotations.length > 0 %}

Imported: {{importDate | format(“DD/MM/YYYY HH:mm”)}}

{%- set annotOld = -%}
{%- set annotOld = annotations | filterby(“date”, “dateonorbefore”, lastImportDate) -%}

{################# Red Annotations #################}

{%- set annotRed = -%}

{%- for a in annotAll -%}
{%- if a[‘colorCategory’] == “Red” -%}
{%- set annotRed = (annotRed.push(a), annotRed) -%}
{%- endif -%}
{%- endfor -%}

{%- set annotRedOld = -%}

{%- for a in annotOld -%}
{%- if a[‘colorCategory’] == “Red” -%}
{%- set annotRedOld = (annotRedOld.push(a), annotRedOld) -%}
{%- endif -%}
{%- endfor -%}

{%- persist “rednotes” -%}

{{ renderHeading(annotRed, annotRedOld, “Disagree with / Sceptical of Author”)}}

{%- if annotRed.length > 0 %}
{%- for annot in annotRed -%}
{{ renderCallout(annot, “red”)}}
{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############## Yellow Annotations ##############}

{%- set annotYellow = -%}

{%- for a in annotAll -%}
{%- if a[‘colorCategory’] == “Yellow” -%}
{%- set annotYellow = (annotYellow.push(a), annotYellow) -%}
{%- endif -%}
{%- endfor -%}

{%- set annotYellowOld = -%}

{%- for a in annotOld -%}
{%- if a[‘colorCategory’] == “Yellow” -%}
{%- set annotYellowOld = (annotYellowOld.push(a), annotYellowOld) -%}
{%- endif -%}
{%- endfor -%}

{%- persist “yellownotes” -%}

{{ renderHeading(annotYellow, annotYellowOld, “Important / Interesting Point by Author”)}}

{%- if annotYellow.length > 0 %}
{%- for annot in annotYellow -%}
{{ renderCallout(annot, “yellow”)}}
{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############## Green Annotations ##############}

{%- set annotGreen = -%}

{%- for a in annotAll -%}
{%- if a[‘colorCategory’] == “Green” -%}
{%- set annotGreen = (annotGreen.push(a), annotGreen) -%}
{%- endif -%}
{%- endfor -%}

{%- set annotGreenOld = -%}

{%- for a in annotOld -%}
{%- if a[‘colorCategory’] == “Green” -%}
{%- set annotGreenOld = (annotGreenOld.push(a), annotGreenOld) -%}
{%- endif -%}
{%- endfor -%}

{%- persist “greennotes” -%}

{{ renderHeading(annotGreen, annotGreenOld, “Very Important”)}}

{%- if annotGreen.length > 0 %}
{%- for annot in annotGreen -%}
{{ renderCallout(annot, “green”)}}
{%- endfor %}
{%- endif %}
{% endpersist -%}

{############### Grey Annotations ################}

{%- set annotGrey = -%}

{%- for a in annotAll -%}
{%- if a[‘colorCategory’] == “Gray” -%}
{%- set annotGrey = (annotGrey.push(a), annotGrey) -%}
{%- endif -%}
{%- endfor -%}

{%- set annotGreyOld = -%}

{%- for a in annotOld -%}
{%- if a[‘colorCategory’] == “Grey” -%}
{%- set annotGreyOld = (annotGreyOld.push(a), annotGreyOld) -%}
{%- endif -%}
{%- endfor -%}

{% persist “greynotes” -%}

{{ renderHeading(annotGrey, annotGreyOld, “Methodology”)}}

{%- if annotGrey.length > 0 %}
{%- for annot in annotGrey -%}
{{ renderCallout(annot, “grey”)}}
{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Purple Annotations ################}

{%- set annotPurple = -%}

{%- for a in annotAll -%}
{%- if a[‘colorCategory’] == “Purple” -%}
{%- set annotPurple = (annotPurple.push(a), annotPurple) -%}
{%- endif -%}
{%- endfor -%}

{%- set annotPurpleOld = -%}

{%- for a in annotOld -%}
{%- if a[‘colorCategory’] == “Purple” -%}
{%- set annotPurpleOld = (annotPurpleOld.push(a), annotPurpleOld) -%}
{%- endif -%}
{%- endfor -%}

{% persist “purplenotes” -%}

{{ renderHeading(annotPurple, annotPurpleOld, “Confused / Have Further Questions”)}}

{%- if annotPurple.length > 0 %}
{%- for annot in annotPurple -%}
{{ renderCallout(annot, “purple”)}}
{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Blue Annotations ################}

{%- set annotBlue = -%}

{%- for a in annotAll -%}
{%- if a[‘colorCategory’] == “Blue” -%}
{%- set annotBlue = (annotBlue.push(a), annotBlue) -%}
{%- endif -%}
{%- endfor -%}

{%- set annotBlueOld = -%}

{%- for a in annotOld -%}
{%- if a[‘colorCategory’] == “Blue” -%}
{%- set annotBlueOld = (annotBlueOld.push(a), annotBlueOld) -%}
{%- endif -%}
{%- endfor -%}

{% persist “bluenotes” -%}

{{ renderHeading(annotBlue, annotBlueOld, “Interesting References / Connected to the Larger Research Question”)}}

{%- if annotBlue.length > 0 %}
{%- for annot in annotBlue -%}
{{ renderCallout(annot, “blue”)}}
{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Orange Annotations ################}

{%- set annotOrange = -%}

{%- for a in annotAll -%}
{%- if a[‘colorCategory’] == “Orange” -%}
{%- set annotOrange = (annotOrange.push(a), annotOrange) -%}
{%- endif -%}
{%- endfor -%}

{%- set annotOrangeOld = -%}

{%- for a in annotOld -%}
{%- if a[‘colorCategory’] == “Orange” -%}
{%- set annotOrangeOld = (annotOrangeOld.push(a), annotOrangeOld) -%}
{%- endif -%}
{%- endfor -%}

{% persist “orangenotes” -%}

{{ renderHeading(annotOrange, annotOrangeOld, “Definitions / Sources for Literature Review”)}}

{%- if annotOrange.length > 0 %}
{%- for annot in annotOrange -%}
{{ renderCallout(annot, “orange”)}}
{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Pink (Magenta in Zotero) Annotations ################}

{%- set annotPink = -%}

{%- for a in annotAll -%}
{%- if a[‘colorCategory’] == “Magenta” -%}
{%- set annotPink = (annotPink.push(a), annotPink) -%}
{%- endif -%}
{%- endfor -%}

{%- set annotPinkOld = -%}

{%- for a in annotOld -%}
{%- if a[‘colorCategory’] == “Magenta” -%}
{%- set annotPinkOld = (annotPinkOld.push(a), annotPinkOld) -%}
{%- endif -%}
{%- endfor -%}

{% persist “pinknotes” -%}

{{ renderHeading(annotPink, annotPinkOld, “Miscellaneous”)}}

{%- if annotPink.length > 0 %}
{%- for annot in annotPink -%}
{{ renderCallout(annot, “pink”)}}
{%- endfor -%}
{%- endif %}
{% endpersist %}
{%- endif -%}

The template is amazing. I have no clue of to program those, so i sadly have to leech off other peoples work lol. Thank you very much :slight_smile:

Hi all, I’ve been updating the template for my own need and I really like the result.
However, I’m wondering if there is a way to import note alongside the outline sections. I’ve been searching for this but didn’t find relevant answer yet.
Does anyone knows if it’s possible to import the pdf table of content and to put annotations/highlights/images in sections with the ToC hierarchy, using Zotero Integration?
Cheers!

Hello community,

A simple basic template, if anyone want to start somewhere

  • Highlight from zotero converted and formatted inside Obsidian (using highlighter obsidian plugin)
  • Headings formatted (only comment: #,##,###,#### to your highlight in Zotero)
  • Undeletable sections each time you re-sync/re-import your document to obsidian. (Practical if you further write in your Obsidian note and don’t want it to be crushed with the new import)

What it looks like :

template :

---
tags:
Date modified: '{{importDate | format ("YYYY-MM-DD")}}'
---
**Auteur(s) :** {{authors}}
**Citationkey :** {{citationKey}}
**Bibliography :** {{bibliography}}
**ZoteroLink** : {{pdfZoteroLink}}
**Date :** {% persist "a" %}{{date | format("YYYY-MM-DD")}} | {% endpersist %}
**ISSBN :** 

> [!NOTE]- Abstract
> {{abstractNote}}

---
**Hard Link (Tagging):** {% persist "H" %}{% endpersist %}
# Résumé  & Notes
{% persist "notes" %}
{% endpersist %}

---
# Essentiel
### Le livre: de quoi il s'agit ?
{% persist "livre" %}
{% endpersist %}
### Points clés
{% persist "clés" %}
{% endpersist %}
### Références à creuser
{% persist "creuser" %}
{% endpersist %}

---
# Annotations
{% for annotation in annotations %}
{%- set colorMap = {
  "yellow": "#FFF3A3A6",
  "red": "#FF5582A6",
  "green": "#BBFABBA6",
  "blue": "#ADCCFFA6",
  "purple": "#D2B3FFA6",
  "magenta": "#FFB8EBA6",
  "orange": "#FFB86CA6",
  "gray": "#CACFD9A6"
} -%}
{%- if annotation.annotatedText %}
{%- if annotation.comment and (annotation.comment == "#" or annotation.comment == "##" or annotation.comment == "###" or annotation.comment == "####" or annotation.comment == "#####") %}
{{annotation.comment}} {{annotation.annotatedText}}
{%- else %}
<mark style="background: {{colorMap[annotation.colorCategory | lower]}}">{{annotation.annotatedText}}</mark> [(p. {{annotation.page}})]({{annotation.desktopURI}})
{%- if annotation.comment %}
- {{annotation.comment}}
{%- endif %}
{%- endif %}
{%- elif annotation.imageRelativePath %}
![[{{annotation.imageRelativePath}}]]
{%- if annotation.comment %}
- {{annotation.comment}}
{%- endif %}
{%- else %}
> {{annotation.comment}} [(p. {{annotation.page}})]({{annotation.desktopURI}})
{%- endif %}
{% endfor -%}

Settings:


Cheers
Charles Collin

1 Like

Here’s a slightly updated version of @adh1b ‘s template. Main changes are:

  • Incorporated the tags code above
  • updated the authors property to be a list of links to authors
  • Made the Abstract visible by default
  • Made the publication a link
  • Added a high profile link to the PDF in Zotero
  • Used an embedded note for taking notes (so that changing plugins etc. won’t ever destroy things that I have written - the literature note can be trashed and started again)
---
title: "{{title | escape}}"
authors: {%- for creator in creators %}{%- if creator.type == author %}
- "[[{%- if creator.name == null %}{{creator.firstName}} {{creator.lastName}}{%- endif -%}{%- if creator.name %}{{creator.name}}{%- endif -%}]]"{%- endif %}
{%- endfor %}
year: {{date | format("YYYY")}}
literature-type: {{itemType}}
publication: "[[{{publicationTitle}}]]"
doi: "{{DOI}}"
doiUrl: "[{{DOI}}](https://doi.org/{{DOI}})"
tags: [{% if allTags %}{% for tag in allTags.split(",") %}{{ tag | trim | replace(" ", "-") }}{% if not loop.last %}, {% endif %}{% endfor %}{% endif %}]
citekey: {{citekey}}
date added: {{exportDate | format("DD/MM/YYYY")}}
cssclass: literature-note
---

# {{title}}
**Authors**:: {%- for creator in creators %} {%- if creator.type == author %}[[{%- if creator.name == null %}{{creator.firstName}} {{creator.lastName}}{%- endif -%}{%- if creator.name %}{{creator.name}}{%- endif -%}]]{% if not loop.last %}, {% endif %}{%- endif %}{%- endfor %}

> [!abstract] 
> {% if abstractNote %} 
> {{abstractNote|replace("\n"," ")}}
> {% endif %}

> [!info] [PDF]({{firstAttachmentZoteroLink}})

> [!info]- Metadata 
> – {% for attachment in attachments | filterby("path", "endswith", ".pdf") %}[PDF{% if not loop.first %} {{loop.index}}{% endif %}]({{attachment.desktopURI|replace("/select/", "/open-pdf/")}}){% if not loop.last %}, {% endif %}{% endfor %}
> **Title**:: {{title}}  
> **Authors**:: {%- for creator in creators %} {%- if creator.name == null %} {{creator.firstName}} {{creator.lastName}}, {%- endif -%} {%- if creator.name %}**{{creator.creatorType | capitalize}}**:: {{creator.name}}{%- endif -%}{%- endfor %}
> **Year**:: {{date | format("YYYY")}} 
> {%- if itemType %}**ItemType**:: {{itemType}}{%- endif %}  
> {%- if itemType == "journalArticle" %}**Journal**:: *{{publicationTitle}}* {%- endif %} {%- if itemType == "bookSection" %}**Book**:: {{publicationTitle}} {%- endif %}
> {% if hashTags %}**Keywords**:: {{hashTags}}{% endif %}
> {%- if DOI %}**DOI**:: {{DOI}}{% endif %}{%- if ISBN %}
> **ISBN**:: {{ISBN}}{% endif %}
> **Related**:: {% for relation in relations -%} {%- if relation.citekey -%} [[{{relation.citekey}}]], {% endif -%} {%- endfor%}

![[Notes/LiteratureNotes/{{citekey}}_notes]]

## Annotations
{%- macro renderHeading(newArr, oldArr, headingText) -%}
	{### Only print the heading on a *first* import of this colour ###}
	{%- if newArr.length > 0 and oldArr.length <= 0 %}
### {{ headingText }}
	{% endif %}
{%- endmacro -%}

{%- macro calloutHeader(type) -%}
    {%- switch type -%}
        {%- case "highlight" -%}
        Highlight
        {%- case "image" -%}
        Figure
        {%- default -%}
        Note
    {%- endswitch -%}
{%- endmacro -%}

{%- macro renderCallout(annot, color) %}
> [!quote{{"|" + color}}]+ {{ calloutHeader(annot.type) }} ([Page {{ annot.pageLabel }}]({{ annot.desktopURI }}))

{%- if annot.annotatedText %}
> {{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}

{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
> - **{{annot.comment|nl2br}}**
{%- endif %}
{% endmacro %}

{%- set annotAll = [] -%}
{%- set annotAll= annotations | filterby("date", "dateafter", lastImportDate) -%}

{% if annotations.length > 0 %}

*Imported: {{importDate | format("DD/MM/YYYY HH:mm")}}*

{%- set annotOld = [] -%}
{%- set annotOld = annotations | filterby("date", "dateonorbefore", lastImportDate) -%}

{################# Red Annotations #################}

{%- set annotRed = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Red" -%}
		{%- set annotRed = (annotRed.push(a), annotRed) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotRedOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Red" -%}
		{%- set annotRedOld = (annotRedOld.push(a), annotRedOld) -%}
	{%- endif -%}
{%- endfor -%}

{%- persist "rednotes" -%}

{{ renderHeading(annotRed, annotRedOld, "Important")}}

{%- if annotRed.length > 0 %}
	{%- for annot in annotRed -%}
		{{ renderCallout(annot, "red")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############## Yellow Annotations ##############}

{%- set annotYellow = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Yellow" -%}
		{%- set annotYellow = (annotYellow.push(a), annotYellow) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotYellowOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Yellow" -%}
		{%- set annotYellowOld = (annotYellowOld.push(a), annotYellowOld) -%}
	{%- endif -%}
{%- endfor -%}

{%- persist "yellownotes" -%}

{{ renderHeading(annotYellow, annotYellowOld, "Highlight")}}

{%- if annotYellow.length > 0 %}
	{%- for annot in annotYellow -%}
		{{ renderCallout(annot, "yellow")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############## Green Annotations ##############}

{%- set annotGreen = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Green" -%}
		{%- set annotGreen = (annotGreen.push(a), annotGreen) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotGreenOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Green" -%}
		{%- set annotGreenOld = (annotGreenOld.push(a), annotGreenOld) -%}
	{%- endif -%}
{%- endfor -%}

{%- persist "greennotes" -%}

{{ renderHeading(annotGreen, annotGreenOld, "Literature/Refs")}}

{%- if annotGreen.length > 0 %}
	{%- for annot in annotGreen -%}
		{{ renderCallout(annot, "green")}}
	{%- endfor %}
{%- endif %}
{% endpersist -%}

{############### Grey Annotations ################}

{%- set annotGrey = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Gray" -%}
		{%- set annotGrey = (annotGrey.push(a), annotGrey) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotGreyOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Grey" -%}
		{%- set annotGreyOld = (annotGreyOld.push(a), annotGreyOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "greynotes" -%}

{{ renderHeading(annotGrey, annotGreyOld, "Methodology")}}

{%- if annotGrey.length > 0 %}
	{%- for annot in annotGrey -%}
		{{ renderCallout(annot, "grey")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Purple Annotations ################}

{%- set annotPurple = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Purple" -%}
		{%- set annotPurple = (annotPurple.push(a), annotPurple) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotPurpleOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Purple" -%}
		{%- set annotPurpleOld = (annotPurpleOld.push(a), annotPurpleOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "purplenotes" -%}

{{ renderHeading(annotPurple, annotPurpleOld, "Confused / Have Further Questions")}}

{%- if annotPurple.length > 0 %}
	{%- for annot in annotPurple -%}
		{{ renderCallout(annot, "purple")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Blue Annotations ################}

{%- set annotBlue = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Blue" -%}
		{%- set annotBlue = (annotBlue.push(a), annotBlue) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotBlueOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Blue" -%}
		{%- set annotBlueOld = (annotBlueOld.push(a), annotBlueOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "bluenotes" -%}

{{ renderHeading(annotBlue, annotBlueOld, "Interesting References / Connected to the Larger Research Question")}}

{%- if annotBlue.length > 0 %}
	{%- for annot in annotBlue -%}
		{{ renderCallout(annot, "blue")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Orange Annotations ################}

{%- set annotOrange = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Orange" -%}
		{%- set annotOrange = (annotOrange.push(a), annotOrange) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotOrangeOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Orange" -%}
		{%- set annotOrangeOld = (annotOrangeOld.push(a), annotOrangeOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "orangenotes" -%}

{{ renderHeading(annotOrange, annotOrangeOld, "Definitions / Sources for Literature Review")}}

{%- if annotOrange.length > 0 %}
	{%- for annot in annotOrange -%}
		{{ renderCallout(annot, "orange")}}
	{%- endfor -%}
{%- endif %}
{% endpersist -%}

{############### Pink (Magenta in Zotero) Annotations ################}

{%- set annotPink = [] -%}

{%- for a in annotAll -%}
	{%- if a['colorCategory'] == "Magenta" -%}
		{%- set annotPink = (annotPink.push(a), annotPink) -%}
	{%- endif -%}
{%- endfor -%}

{%- set annotPinkOld = [] -%}

{%- for a in annotOld -%}
	{%- if a['colorCategory'] == "Magenta" -%}
		{%- set annotPinkOld = (annotPinkOld.push(a), annotPinkOld) -%}
	{%- endif -%}
{%- endfor -%}

{% persist "pinknotes" -%}

{{ renderHeading(annotPink, annotPinkOld, "Miscellaneous")}}

{%- if annotPink.length > 0 %}
	{%- for annot in annotPink -%}
		{{ renderCallout(annot, "pink")}}
	{%- endfor -%}
{%- endif %}
{% endpersist %}
{%- endif -%}
```

A bit late to the party, but here is mine.

It uses color coded annotations in Zotero to create a structured overview for a publication in Obsidian. You can find the template with more information on my Github (username is also citingfairy, can’t post links here).

This is the template:

---
cssclasses:
  - literature-note
tags:
date-created: "{{exportDate | format('YYYY-MM-DD')}}"
title: "{{title}}"
item-type: "{{itemType | capitalize}}"
signature: {% if archive %}"{{archive}}, {{archiveLocation}}, {{callNumber}}"{% endif %}
authors: {% for creator in creators | filterby("creatorType", "contains", "author") %}
  - "{{creator.lastName}}, {{creator.firstName}}"{% endfor %}
recipient: {% if itemType == "letter" %}"{{recipients}}"{% endif %}
lit-date-daily: {% if itemType == "newspaperArticle" or "report" or "letter" %}"{{date | format("YYYY-MM-DD")}}"{% endif %}
lit-date-yearly: "{{date | format("YYYY")}}"
editors: {% if itemType == "bookSection" %}"{{editors}}"{% endif %}
edited-book: {% if itemType == "bookSection" %}"{{bookTitle}}"{% endif %}
journal: {% if itemType == "journalArticle" %}"{{publicationTitle}}"{% endif %}
DOI: "{{DOI}}"
annotated: {% if annotations %}"true"{% else %}"false"{% endif %}
type: "zotero-entry"
---
# {{authors}}: {{title}} ({{date | format("YYYY")}})

>[!info] Metadata
>
>* Title: {{title}}
>* Item Type: {{itemType | capitalize}}{% if archive %}
>* Signatur: [[{{archive}}, {{archiveLocation}}, {{callNumber}}]]{% endif %}
>* Autor(s): {{authors}}{% if itemType == "letter" %}
>* Publikum: {{recipients}}{%endif %}{% if itemType == "newspaperArticle" or "report" or "letter" %}
>* Date: {{date | format("YYYY-MM-DD")}}{% else %}
>* Year: {{date | format("YYYY")}}{% endif %}{% if itemType == "bookSection" %}
>* In: {{editors}} (ed.): *{{bookTitle}}*{% elif itemType == "journalArticle" %}
>* In: *{{publicationTitle}}* {{volume}} ({{issue}}){% endif %}{% if DOI %}
>* DOI: {{DOI}}{% endif %}
>* Topics: {% for collection in collections %}[[{{collection.name}}]]{% if not loop.last %}, {% endif %}{% endfor %}
>* Cite key: @{{citekey}}

## Links
[Zotero-Link]({{select}})
{% if attachments %}
{% for attachment in attachments %}{% if attachment.select %}[{{attachment.title}}]({{attachment.select}}){% elif attachment.url %}[Online]({{attachment.url}}){% endif %}{% endfor %}{% endif %}

{%- macro citation(creators, pageLabel, annotlink) %}
{%- set auths = creators | filterby("creatorType", "startswith", "author") -%}
([{% if auths | length < 3 and auths | length != 0 %}{% for na in auths %}{{na.lastName}}{% if not loop.last %} and {% endif %}{% endfor %}{% elif auths | length %}{% for na in creators %}{% if loop.first %}{{na.lastName}} et al.{% endif %}{% endfor %}{% else %}@{{citekey}}{% endif %}](@{{citekey}}), {{date | format("YYYY")}}, [p. {{pageLabel}}]({{annotlink}}))
{% endmacro -%}
{%- set annots = annotations | filterby("date", "dateafter", lastImportDate) %}

{% persist "annotations" %}

{%- if annots.length > 0 -%}
{%- for color, annots in annots | groupby("color") -%}
{%- if color == "#e56eee" %}
## Main Claims and Questions
{% for annot in annots -%}
{%- if annot.comment %}
{{annot.comment | nl2br}}
{%- endif %}
> [!quote|{{color}}]
> {{annot.annotatedText | nl2br}}
>
>{{citation(creators, annot.pageLabel, annot.desktopURI)}}

{%- endfor -%}
{%- endif -%}
{%- if color == "#5fb236" -%}
## Core Quotes
{% for annot in annots -%}
{%- if annot.comment %}
{{annot.comment | nl2br}}
{%- endif %}
> [!quote|{{color}}]
> {{annot.annotatedText | nl2br}}
>
>{{citation(creators, annot.pageLabel, annot.desktopURI)}}

{%- endfor -%}
{%- endif -%}
{%- endfor %}
## Excerpts and Comments
{% for annot in annots -%}
{% if annot.color == "#f19837" -%}
### {{annot.annotatedText | nl2br}}
{% if annot.comment %}
{{annot.comment | nl2br}} {{citation(creators, annot.pageLabel, annot.desktopURI)}}
{%- endif -%}
{%- else %}
{%- if annot.annotatedText or annot.imageRelativePath %}
> [!quote{% if annot.color %}|{{annot.color}}{% endif %}]
{%- if annot.annotatedText %}
> {{annot.annotatedText | nl2br}}
{%- endif -%}
{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}
{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}
>
> {{citation(creators, annot.pageLabel, annot.desktopURI)}}
{%- if annot.comment %}
{{annot.comment | nl2br}}
{% endif %}{% else %}{% if annot.comment %}
{{annot.comment | nl2br}} {{citation(creators, annot.pageLabel, annot.desktopURI)}}{% endif -%}
{%- endif -%}

{%- endif %}{% endfor -%}
{% else %}
## Notes
{% endif %}
{% endpersist %}