I am primarily a MacOS user who does most of my analytics and presentation work in R / RStudio / RMarkdown, so it was natural to take advantage of using the R blogdown package.

Many others have already documented nice tutorials on how to get a blog started with blogdown, Hugo, GitHub, and Netlify, so I’ll just reference a number of resources that I found particularly helpful. Also, I chose to use the tranquilpeak Hugo theme, as I liked the look of it, and it generally seems to play well in this environment.

computer screen

Recipe for getting started

  • Up and running with blogdown by Alison Presmanes Hill
    • a remarkably clear set of instructions on getting started with blogdown, GitHub, and Netlify

Other helpful resources

Steps for setting up

I pretty much followed the steps described by Alison Presmanes Hill, with a few minor changes and tweaks.

  • Created a GitHub repository (private)
    • initially I planned to make it Public, but because I’m often analyzing clinical datasets, I didn’t want to risk accidentally exposing protected health information
  • Developed in RStudio
    • installed blogdown and Hugo
    • created a blogdown::newsite() using the tranquilpeak theme
  • Deployed with Netlify
    • by default Netlify builds with hugo_0.19, but tranquilpeak requires hugo_0.20
    • no worries – it’s easy to choose a different version
    • set Build command to just hugo
    • set the Build environmental variable of HUGO_VERSION to 0.38.1
  • Obtained a domain name

Additional tweaks and discoveries

  • Custom blog post summaries on the index page don’t work in posts built from Rmd (at least for the tranquilpeak theme)

    • In markdown posts, all text above <!--more--> are used for the post summary on the index page
    • However, this doesn’t work for Rmarkdown posts
    • Instead, it’s possible to modify the theme to be able to specify a custom summary in the YAML header
  • Most methods of syntax highlighting don’t seem to fully support R code

    • best solution so far seems to be to use the highlight tag, which might be specific to tranquilpeak

The following (remove the space between the {’s, as I can’t figure out how to escape the {):

{ {< highlight r >}}
library(tidyverse) # a comment
x <- mean(mtcars$mpg)
{ {< /highlight >}}


library(tidyverse) # a comment
x <- mean(mtcars$mpg)