GitHub pages subdirectory hassle

This blog is hosted on GitHub pages. It is automatically generated from Markdown source files by Jekyll every time a commit is pushed to the gh-pages branch of the GitHub repo corresponding to the blog.

I have a private repo called ‘blog’, and under normal circumstances its ‘project page’ (actually my blog) would appear at, say,

GitHub’s Jekyll process seems to be clever enough to handle this and ensure that html links in the source code are rendered correctly as links relative to this base URL.

However, I use a custom domain which corresponds to (A record set with DNS provider, and CNAME file stored in GitHub repo per instructions). This leads to borked URL rendering when the blog at is accessed. Symptoms include URLs with two forward slashes and missing CSS styling.

The solution is buried here in the Jekyll documentation and it works like a charm: