How to start a data blog with R + Hugo + Blogdown in 10 short steps

Dec 15, 2017 00:00 · 539 words · 3 minute read R blogdown hugo

I just finished creating this blog to share stories, teach R skills, create environmental data stories, and most importantly - shamelesly self-promote. It makes sense to share with you a minimal formula for starting your own data blog with R.

Yihui Xie, the master behind Rmarkdown, has kindly created a great framework for blogging with R - blogdown. Blogdown creates Hugo (one of the most popular open-source static site generators) websites, and allows you to write new content using markdown or Rmarkdown. This makes it really easy to create posts sharing R code and workflows. He has created a great, comprehensive guide available here. But the process is so simple you can achieve it in 10 simple steps:

  1. Create a new project in Rstudio in a new folder

  2. Install the blogdown package

  1. Install Hugo (from within R)
  1. Choose a theme for your blog from - beware not all of them have been tested with blogdown

  2. Create your new site from this template. The string we use for the theme is the github site where the theme is hosted. The example below uses the hugo-academic theme hosted at

blogdown::new_site(theme = "gcushen/hugo-academic")
  1. This will automatically download all the files for your site into your project folder. You can now start editing these files to customise your site.
  • Edit the config.toml file to change theme settings and general paramters of your site such as author, site description etc
  • Add images that you will use to the folder static/images in your project home directory
  • Edit your sites content by editing the pages within the content folder in your project home directory. Here you can add new blog posts, or editing existing content
  1. You can also add new blog posts using the handy Rstudio addin that comes with blogdown, just click Tools > Addins > Browse Addins and select New Post. You can specify the post title, dates, tags and categories using this tool.
    The same functionality can be acheived using a blogdown function:
  1. Now you have a website, you probably want to share it with others. First create a repo on github for your website. Then initialize your project folder and push it to that repo. After navigating to your project directory:
git init
git remote add origin
git add .
git commit -m "first commit"
git push origin master

You will want to create a .gitgnore to prevent unessasary files from being pushed to git. An example .gitignore would be:


  1. Create an account at Netlify, it’s free. Choose the option to create a new site from git, and after loggining into your github account select the repository containing your website. When prompted, choose to deploy the master branch, and type hugo for build command and public for publish directory. This should start the deploy of your website. If all goes well, you should get a link to your new site and viola your website is live

  2. Pat yourself on the back

Making updates and new posts to your site is as simply as making the change or adding the post locally in your R project, and pushing the changes to github. Netlify will automatically rebuild the website whenever you update the repo

tweet Share