Zotero integration template - annotations not displaying

What I’m trying to do

I’m trying to import the annotations from PDF files in Zotero using a custom template. When I import a paper with annotations from zotero using the plugin’s “Import notes” function, the annotations are imported into obsidian. When I look at the same paper using Data Explorer, it shows that the paper has 2 annotations to import. But when I try to use a custom template the annotations collection appears to be empty.

Here is my template:

---
title: {{title}}
authors: [{{authors}}]
aliases:{{citekey}}
citekey: {{citekey}}
keywords: [{{alltags}}]
type: paper
---

### Notes

{% if annotations.length >0 %}
	Hello!
{% else %}
	Print nothing
{% endif %}

This template shows “Print nothing” in the Notes field when I import the paper, suggesting that the annotations collection is empty.
If I change the template code to use the creators collection i.e.

{% if creators.length >0 %}
	Hello!
{% else %}
	Print nothing
{% endif %}

the output is “Hello!”, so the template code does work.

I can’t find any info on what might be causing this.

Any suggestions please?

Not looking at the template now – just came to mind that one needs to extract annotations first in Zotero?

And there’s a whole thread here to try out other templates:

Hello,
Thanks for the suggestion. I’ve been reading through that thread and came across some discussion about the differences between zotero 5 and 6. Most of my references in zotero were imported using the older version 5, so I went and downloaded a new reference to test with. The import works perfectly with the new file, so maybe there is a problem with some of the pdfs imported in the old version.

I appear to have lost all of the annotations made on the pdfs under previous versions of zotero (gulp). A bonus of importing annotations into obsidian will be having a second copy of my notes!

There is even 7 now which I’m reluctant to try until all plugins are updated to work with it.

I’m not sure how that happens.
If you are interested in a solution, try postiing a question on the Zotero forums where the developers and and forum frequenters are always very helpful.
Otherwise try searching the forums there to look for some solution.

Regards

1 Like

Beyond the incompatibilities / data corruptions you may have had, there could be several reasons for this situation.

For example: If there is more than one attachment, attachments will only contain annotations from the first one. This might not be the one you annotated. In the case of several attachments, you need iterate over the attachments array instead.

@gino_m Extracting the annotations to a note is not necessary. Zotero Integration can access them regardless. Of course, given that the template is set up correctly and accesses attachments or annotations.

1 Like