Using static website generators (SSG) like nanoc, Jekyll, or Hugo to automatically build a website based on R markdown documents currently requires dealing with a couple of technical details.
knitr
to turn the R markdown documents into regular markdown. I use an R script that gets called from a Makefile.knitr
ignores YAML front matter in R markdown files, so this is fine.This website is currently (2024) built with nanoc (version 4.12.5, compatibility options for working with nanoc3 config), using Ruby (version 3.0.2). The design uses the Bootstrap framework (version 5.3.3). As a markdown engine, I use pandoc (version 2.9) because it provides
knitr
defaultThe build-process is automatically managed with a Makefile that calls an R-script for knitting R markdown files to plain markdown. To build this website yourself:
knitr
package. Set a permanent R option which CRAN mirror to use by creating a file .Rprofile
in your home directory, containing the line options(repos=c(CRAN="https://cran.rstudio.com/"))
. Also install pandoc, Ruby, as well as the Ruby gems nanoc and pandoc-ruby.https://github.com/dwoll/RExRepos.git
.nanoc
to build the already present markdown files. To build from R markdown, run make clean
and make
. Doing this under Windows has not been tested since 2013. In theory, it requires editing the Makefiles first, commenting the Linux rm
commands, und un-commenting the Windows del
commands. On Windows, you need to have make and sed installed, and in your path.The following description is based on my experience in 2013, and has not been validated since.
A website like this could also be built with Jekyll. However, Jekyll is less suited for building a navigation structure as it does not let you use embedded Ruby in templates (like nanoc does). The best choice for a markdown engine currently seems to be kramdown. Using Jekyll with kramdown has some extra requirements:
knitr::render_jekyll()
before you knit an R markdown file to plain markdown. This embeds code snippets in curly braces - kramdown doesn’t support fenced code blocks with backticks (knitr’s default).sets
. You have to replace them before running Jekyll.knitr
-based online publication is possible with the R package blogdown which supports Hugo.
A new package for building entire websites based on files in syntax very similar to R markdown files is Quarto