Zotero Integration: "related" not working properly in Obsidian

What I’m trying to do

Hello. I have a template for Zotero Integration borrowed from Bryan Jenks on Youtube, but the {{relation.citekey}} doesn’t return anything despite the paper I import having related in Zotero. Here is the template:

---
Title: "{{title}}"
Authors: {{authors}}{{directors}}
Year: {{date | format("YYYY")}}
keywords: {{allTags}}
status: 
tags:
  - 🟥
  - ⌛
  - ✅
{% for relation in relations -%}
{%- if relation.citekey -%}
related: {{relation.citekey}}
{% endif -%}
{%- endfor %}
---

It works fine if there is one related, however if it’s two or more, it duplicates the “related:” text before adding them, as such:

related: Test1.etal2011
related: Test2.etal2022

Any ideas what the reason could be and how to fix so it shows all the related on the same line?

Thank you in advance.

I don’t use the plugin or Zotero but it looks like the “related:” is included in a loop. That “for relation in relations” part means “for each relation in the group of relations, do the following”. If you move “related:” (but not the bracketed stuff after it) above that “for” line, the “related” will not be repeated — but other items will each be on their own line. I don’t know how to get them on the same line — maybe the plugin’s documentation explains, or links to something that explains.

related:
{% for relation in relations -%}
{%- if relation.citekey -%}
{{relation.citekey}}
{% endif -%}
{%- endfor %}

Hey, thank you for your answer. It works.

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