erazlogo / obsidian-history-vault

A starter vault for historical research with Zotero and Obsidian.
85 stars 1 forks source link

Adding tags field to YAML #1

Closed cordovero closed 2 years ago

cordovero commented 2 years ago

Hello,

I have been really inspired by your Zotero/Obsidian workflow. However, I'm also really terrible at coding... For my workflow, I would really need to be able to add the tags from the Zotero object within the YAML field of the imported annotation. I have tried pasting your tags code within a tag field in the template (in the YAML frontmatter) but I always get a parsing error. I attach a screen cap of the modifications I've attempted within the template, as well as the error message. I'm quite lost! Thank you so much!

Capture d’écran 2022-06-22 à 18 13 32
erazlogo commented 2 years ago

Tags in YAML are formatted differently--see here: https://help.obsidian.md/How+to/Working+with+tags#Add+tags Try this:

{% if tags.length > 0 -%}Themes: 
{% for t in tags -%}
- {{t.tag | lower | replace(" ", "-")}}{% if not loop.last %}
{% endif %}{% endfor %}{%- endif %}

I think {% if themes %} is what is giving you the error--try deleting that.

cordovero commented 2 years ago

Thank you so much, that worked wonders! I had assumed the tag field in the template would work in the YAML frontmatter... Again, thank you for all your work!