Using a bib references file from an online source

I've uploaded my .bib references library online, so I can share it with collaborators and across projects

However, I cannot get it to work.

here's my YAML header:

---
title: My title
output:
  bookdown::html_document2:
    toc: yes
    toc_depth: 4
    toc_float: yes
    self_contained: yes
    number_sections: FALSE
bibliography: https://gist.github.com/MavropaliasG/a29a383441513e4292c86d1f9f11b559/raw/61bde4e8648a37b023add03574553e551919dac1/MyLibrary.bib
csl: https://www.zotero.org/styles/vancouver-brackets-only-year-no-issue
---

However, even if I put the bibliography path in quotation marks, I get this:

pandoc: https://gist.github.com/MavropaliasG/a29a383441513e4292c86d1f9f11b559/raw/61bde4e8648a37b023add03574553e551919dac1/MyLibrary.bib: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
In addition: There were 13 warnings (use warnings() to see them)
Execution halted

Is there a way to do this?

I think the issue is that the .bib file is expected to be a local file, so a real hacky solution like this works:

---
title: My title
output:
  bookdown::html_document2:
  toc: yes
  toc_depth: 4
  toc_float: yes
  self_contained: yes
  number_sections: FALSE
bibliography: '`r x <- tempfile(fileext = ".bib"); writeLines(readLines("https://gist.github.com/MavropaliasG/a29a383441513e4292c86d1f9f11b559/raw/61bde4e8648a37b023add03574553e551919dac1/MyLibrary.bib"), x); x`'
csl: https://www.zotero.org/styles/vancouver-brackets-only-year-no-issue
---

Here is [@aagaardAutogenicRecurrentRenshaw2018] and [@abbottPhysiologicalCostNegative1952]
1 Like

That worked! Thank you

1 Like

Great hackish solution @mattwarkentin!

Note that you can also do that from an R chunk within the document

---
title: test
bibliography: MyLibrary.bib
---

```{r, include = FALSE}
xfun::download_file("https://gist.github.com/MavropaliasG/a29a383441513e4292c86d1f9f11b559/raw/61bde4e8648a37b023add03574553e551919dac1/MyLibrary.bib")
```

See [@aagaardSpinalSupraspinalControl2018]

# References
1 Like

Nice solve, @cderv. That's actually what I wanted to do but didn't think it through enough.

1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.