I thought it was worth posting about how I set up this blog as I had enormous trouble setting it up. I’d never done anything like this before and so some Google searching exposed me to many different technologies, but I had no clue what they did, which were best/easiest to work with and which combination I needed to use them in.
First off, big thanks go to John Muschelli and his YouTube video which got me up and running in no time.
So if you want to go the route I have, you need several things installed on your machine:
blogdownpackage (obtained via the usual
- Hugo - you can install it from the
You will also need accounts with Github and Netlify.
John’s video explains how to go through the set-up process better than I can, but I do want to briefly explain my workflow (based on my limited understanding so far). To update my blog with a new post, these are the steps I take:
- I create a new markdown file for a new blog post, and save it in my
- I rebuild my site on my local machine with the command
blogdown::build_site(). This sets off the website generation software Hugo which sits behind
blogdownto create the required HTML pages in the
publicfolder holds all the files needed for the website.
- I register these changes with Git on my local machine, by staging and committing these changes from within RStudio (Tools>Version Control>Commit);
- I upload all of this to my GitHub repository by hitting the Push button.
That’s it! Once my GitHub repository updates, Netlify automatically refreshes my blog by recognising the
public/ folder has changed.
My task now is to figure out how to use a different Hugo theme without breaking everything!
After reading the
blogdown documentation a bit more carefully, I’ve modified my workflow to let Netlify build my website for me. This required making the following changes:
- Deleting the
public/folder and pushing the changes to GitHub;
- Adding the
public/folder to the .gitignore file and pushing to GitHub;
- Modifying my Netlify settings to build using the
hugobuild command (and setting a
I’ve now replaced step 2 with running a
blogdown::serve_site() command so I can view a local version of my website and see updates happen as I make them. This automatically builds the necessary HTML pages for RMarkdown pages (as Hugo cannot do it itself).
Unfortunately, stopping the server crashes RStudio, so I have to run
options(blogdown.generator.server = TRUE) before running it to stop it crashing when it’s stopped. Helpfully, I’ve found I can create a .Rprofile file in the website root directory containing this command so it loads automatically every time I load the project.