Skip to content

Instantly share code, notes, and snippets.

@nickynicolson
Last active May 16, 2022 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickynicolson/03670a4062aecd9d8a309eb7f258db70 to your computer and use it in GitHub Desktop.
Save nickynicolson/03670a4062aecd9d8a309eb7f258db70 to your computer and use it in GitHub Desktop.
Linking Obsidian and Zotero

Linking Obsidian and Zotero

Setup

Zotero

Zotero desktop used to manage literature references, with zotfile and zotero better bibtex plugins used to manage PDF attachments and create / maintain biblatex format downloads respectively.

Obsidian

Obsidian used to manage notes and tasks, with the citations plugin used to access literature references from the Zotero biblatex format export.

Aim

A literature note built in Obsidian should include a link to the PDF version of the article if available.

This should be achieved without overloading the Obsidian vault with all PDF attachments (which may slow Obsidian startup time, and affect usability of file navigation in the UI).

Solution

  • Zotero BibLatex export to include a file field in each biblatex entry, which contains only the PDF filename (ie no path).
  • Obsidian citations plugin to build a markdown format link to the PDF attachment file.

Custom Zotero setup

The zotero better bibtex export has the "postscript" option, which allows the user to define in Javascript modifications to the biblatex entry as it is being created. This process is documented here: https://retorque.re/zotero-better-bibtex/exporting/scripting/

The following postscript snippet was applied to the biblatex export:

if (Translator.BetterBibLaTeX) {
    var attachments = item.attachments
    if (attachments) {
        entry.add({name:'file', value: attachments[0].title, enc:'verbatim'})
    }
}

This ensures that the file field in the BibLatex entry contains only the file name of the PDF attachment, not the full path (as is default).

Custom Obsidian setup

The citations plugin allows the user to modify the literature note content template. As we know the location of the PDF attachment directory used by Zotero, the literature note can be modified to include a markdown format file:/// link to the PDF file:

{{authorString}} ([[{{year}}]]) **[[{{citekey}}.pdf|{{title}}]]**. *{{containerTitle}}* | doi:[{{DOI}}](https://doi.org/{{DOI}}) | @{{citekey}} [{{entry.files}}](file:///PATH_OF_PDF_ATTACHMENT_DIRECTORY/{{entry.files}}) ^apalike

A literature note now includes a link through to the full text of the article.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment