After getting a barebones Jekyll install up and running, my next step was to work out how to post R Markdown files to it. There is nothing wrong with regular markdown, but after using R for several years and LaTeX for many more years, I preferred the larger set of possibilities that come with R Markdown.

There are two major routes to work with R Markdown source files with Jekyll, one involves using the Jekyll plugins system, and the other uses R (in effect the knitr::render_jekyll() function) to pre-process all R Markdown files to Jekyll-compatible markdown files.

The plugins route appeared quite convoluted, and being unfamiliar with Ruby, gems, etc. did not make my situation any better. I found a few pages describing the process, but the temptation of using more familiar tools was too great.

## R (knitr) pre-process route

I used all of the listed pages for inspiration, but I based my solution heavily on dfeng’s make.R script.

In my Jekyll site source directory, I created a _knitr directory, which will hold R Markdown files. In the same directory, I placed my Rmd -> md conversion script (called render_post.R).

Now we just need to run this script whenever we have new or updated Rmd-files in the _knitr directory. Since I already created a bash script that handles the jekyll build command, I decided to handle the R script in the same place.

This way, we keep the Jekyll source directory exclusively on the local machine, and only sync the site directory with the remote machine (the public-facing server). We still need to maintain a Jekyll install on both the local and remote machine, though – haven’t found a way around that. Correction: we only require a Jekyll stack on the machine where we build the site. Once Jekyll has built the site, the result is just a bunch of html, css and js that can be served to almost any browser.