Bernhard Bieri


August 10, 2022

This is a quick tips & tricks post I decided to write after switching my personal website to the Hugo Apero theme by using this excellent guide by Silvia Canelon. In it, she describes how she uses branches to switch from one theme to the other without breaking the initial site. The original idea came from the following Twitter thread by the following Tweet by Garrick Aden-Buie and leverages what is known as “Branch Deploys” on Netlify.

{{% tweet "1384960915276275715" %}}

Previously, I used to write my entire blog post, served it locally to make sure it rendered correctly, and published it on the main branch of my repository. This in turn triggered a build instruction on Netlify which built the site with the new post. While this workflow is fine for simple blogs with a single author, I ended up switching to using branches to compartmentalize individual blog posts, render them on a branch deploy on the web to see the final product and to avoid breaking the main site while experimenting things on branches.

Hence, I switched to the following workflow to write new content:

  1. Head to the site’s settings on Netlify and activate branch deploys for all branches.
  2. Create a new branch titled after the blog post I want to write
  3. Create a new blog post using blogdown::new_post()
  4. Write the actual post
  5. Commit and push the changes on the new branch

And that’s already it!

NB: I am unsure why but when selecting specific branches of my repository the branch deploys did not work when I pushed changes to GitHub.

Back to top



For attribution, please cite this work as:
Bieri, Bernhard. 2022. “Introducing Branches to Your {Blogdown} Workflow.” August 10, 2022.