Using Blogdown to Start a Blog đź“ť

Sam Parmar
2 min readNov 30, 2020

--

Note: This article was originally written by me on July 21, 2020.

Blogdown makes it very easy for R programmers to build a personal website and/or blog. If you’re an avid R user and don’t have a personal website or blog, you need to check out Yihui’s book on blogdown! It is very easy to get started.

Here’s what I did to start a blog using R.

Quick Steps

  1. Installed the Blogdown package:
    install.packages('blogdown')
  2. Installed Hugo which is the static site generator that blogdown is based on:
    blogdown::install_hugo()
  3. Created a new project under a new directory:
    File -> New Project
  4. Called new site function:
    blogdown::new_site()
  5. Examined example website that was built. Impressed by LiveReload feature of Blogdown that “automagically” rebuilds and reloads the websites with any source file modification/save.
  6. Inspected other Hugo themes. Decided on the Hugo Novela theme. Launched function to create new site with the chosen theme:
    blogdown::new_site(theme = 'forestryio/hugo-theme-novela')
  7. Explored project directory structure and updated relevant markdown files to initialize website.
  8. Added following parameter to config.toml file: relativeurls = true
  9. Restarted Rstudio and reopened my R project. Then rebuilt the website: blogdown::hugo_build()

What’s amazing is that this whole process was completed in under an hour and there I was writing my first blog post.

  • After the blog was built. I went over to Github and created a new repo for my blog.
  • Then I went into the settings for the repo, went to the Github Pages section, and setup the Source to be the master branch of my website
  • Lastly, I put the public directory from my project into my Github repo.

Future direction

I needed to put something together quickly, with what I already knew. From what I’ve recently read, after step 9 is not the recommended approach to take, but it works for the time being. In the near future, I could use Netlify + Github to take advantage of the continuous depoloyment feature of Netlify.

Motivation

Yihui is a very funny and insightful guy. In this video, he mentions that the most important lesson he learned from writing nearly a thousand blog posts is "Listen/read/tweet and forget; write and remember!"

References:

  • Xie, Yihui, Alison Presmanes Hill, and Amber Thomas. Blogdown: creating websites with R markdown. CRC Press, 2017.

--

--

Sam Parmar
Sam Parmar

No responses yet