Whether due to broken CSS or a change that seems to have had no effect, sometimes it is necessary to force a rebuild of a Jekyll website hosted on GitHub. Today’s pro tip explains one way to do this.

@jess.temporal Empty commits are awesome! That is, if you know how to make them #git #coding #softwareengineer #github #gittutorial #tutorial #techtok #technology ♬ Empty commit - Jess Temporal

What is GitHub Pages?

GitHub has a “service” for serving pages from repositories called GitHub Pages. This service allows you to create pages almost instantly from your repository and all you need is a markdown file like a project’s README.md and a basic configuration file.

This is possible because GitHub Pages uses Jekyll, an open source static website generator, to build websites. Among other features that I won’t talk about today, an extremely positive point of using these two tools to get your website up and running is that you don’t need to push a build of your website to GitHub every time you want to publish a change. GitHub itself takes care of building the website for you.

However, sometimes it is necessary to run the build process again and as this process happens on GitHub servers that we do not have access to, we need other ways to force the build.

Making an empty commit

One of the ways to force a rebuild and the way I use nowadays is to make an “empty” commit, that is, a commit that does not upload changes to any file in your directory.

Just go to the website directory (here I will use my website as an example):

$ cd jtemporal.github.io

and write a commit using the --allow-empty option:

~/jtemporal.github.io $ git commit --allow-empty -m "Forcing website rebuild"

or if you prefer to edit the commit message in the text editor:

~/jtemporal.github.io $ git commit --allow-empty

And that’s it. This is enough to force the build process again. Cool, right? 😜