How to make tags persist after re-importing from Zotero

What I’m trying to do

I have the following template in Obsidian which I use along with the Zotero Integration plugin. There is a YAML preamble to format the paper metadata, followed by two sections where I take notes directly in Obsidian, followed by a section for highlighted text and pictures imported from Zotero. The “Main points” and “Notes” sections are persistent, so that if I take some notes and then re-import, and I don’t lose the notes. I would like to do the same for any tags I have applied to this note in the YAML section (i.e. the last line in the YAML block), but I don’t know how to make the persist blocks work within YAML. Any ideas?

Things I have tried

I tried just naively adding the same kind of persist block I am already using directly within the YAML, but that causes errors since the YAML section is parsed differently than the markdown.

Actual template


title: “{{title}}”
authors: “{{authors}}”
date: ‘{{date | format (“YYYY-MM-DD”)}}’
publication: “{{publicationTitle}}”
doi: “{{DOI}}”
url: “{{url}}”
tags:

Zotero: {{pdfZoteroLink}}

{{abstractNote}}

Main points


{% persist “main points” %}

{% endpersist %}

Notes


{% persist “notes” %}

{% endpersist %}

Figures & Annotations


{% for annotation in annotations -%}
{%- if annotation.annotatedText -%}
> {{annotation.annotatedText | escape}} Page {{annotation.page}}
{%- if annotation.comment %}
- {{annotation.comment}}
{%- endif %}
{{- “\n” -}}
{%- endif %}
{%- if annotation.imageRelativePath -%}
![[{{annotation.imageRelativePath}}]]
{{- “\n” -}}
{%- endif %}
{% endfor %}

I know it’s not exactly what you wanted, but my solutions for the zotero integration are:

(1) do all my tagging in Zotero. That way the tags are always there and just get re-imported. Here is my code to import all tags:

tags: {% if tags.length > 0 -%}
{%- for t in tags -%}
{%- set replaced_tag = t.tag %}
{%- set replaced_tag = replaced_tag | lower | replace(" ", “-”) -%}
{{ "\n - " ~ replaced_tag }}
{%- endfor %}
{%- endif %}

(2) alternatively, you could place your tags outside of the yaml and have them persist in their own block. If you’re using dataview, it can find additional properties as long as they are followed by a double colon, e.g.,

tags:: tag-number-one

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.