Search code examples
rbibliographycitationsblogdown

How to cite using bibtex in blogdown?


I would like to use citations on a page of my static website created with the R package blogdown. Based on the book written about blogdown (https://bookdown.org/yihui/blogdown/#) this seems to be possible. However, I do not not know exactly how to set this up. I know how to do this in a rmarkdown file and in a bookdown file, but not in the context of a website created with blogdown.

First, I created a new post using the new_post() function in the blogdown package. Second, I added bibliography: [references.bib] and @R-base to the post:

---
title: publications
author: ~
date: '2017-09-25'
slug: publications
categories: []
tags: []
header:
  caption: ''
  image: ''

bibliography: [references.bib]

---

@R-base

where the file references.bib is located in the same folder as the post containing

@Manual{R-base,
  title = {R: A Language and Environment for Statistical
    Computing},
  author = {{R Core Team}},
  organization = {R Foundation for Statistical Computing},
  address = {Vienna, Austria},
  year = {2016},
  url = {https://www.R-project.org/},
}

Thank you in advance for your help!

EDIT: I now created a Github repo with as theme academic: repo. To keep it as simple as possible, I only added the publications post (see content/post) and the file references.bib to the example site of the academic theme. These two files exactly match the publications post and references.bib file that were shown above.


Solution

  • I tried your website on github. The problem is that you used a md file for your bibliography, but if you want bookdown to process it, you need to save it as a Rmd file.
    By the way, I guess that what you want is not the citations like (R core team, 2016) but directly the list of publications like:

    R Core Team. 2016. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.

    Thus, you should use this kind of header saved in a Rmd file:

    ---
    title: publicationsRmd
    author: Me
    date: '2017-09-26'
    slug: publicationsrmd
    categories: ["biblio"]
    tags: ["tag"]
    bibliography: [references.bib]
    nocite: | 
      @R-base
    ---