Hosting a blogdown blog on github pages

[This article was first published on s3alfisc.github.io/blog/, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I have recently moved from building this blog via the distill package to blogdown. The main reason for this is that, at the time of writing, distill does not support full RSS feeds for multiple articles, which is a requirement for linking my blog to R-bloggers. Deploying the distill based blog via github pages was quite straightforward, but doing so for the blogdown based blog proved to be slightly more cumbersome.

While there are many good blog posts on deploying blogdown-blogs on github pages (e.g. here or here), I appear not to be the only one who ran into problems, as this stackoverflow thread with 100+ upvotes shows.

In my case, I needed to do two things for successful deployment on github pages:

  1. Add a .nojekyll file to the main directory of the blog, e.g. by running file.create(".nojekyll") in the r console
  2. Add a publishDir: docs statement below baseurl in the config.yaml file. Rebuilding via blogdown::build_site() then creates a docs folder and populates it with html. On github pages, I then needed to make sure that the blog is build based on this docs folder (see the image below). After that, I simply had to commit, push, and github actions would finally deploy the blog without any error messages!
Build the github pages site from the 'docs' folder

Figure 1: Build the github pages site from the ‘docs’ folder

To leave a comment for the author, please follow the link and comment on their blog: s3alfisc.github.io/blog/.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)