#WordPress to #Jekyll Part 4 - Hosting on #GitHub Pages

In the previous posts I have concentrated on generating a static site on your workstation and integrating your content from WordPress. Fortunately, the static content can be hosted anywhere but there are some publicly available services that offer a pipeline for continuous delivery like GitHub Pages.

GitHub Pages

GitHub has launched its own static site generator based on Jekyll called GitHub Pages. It assumes you placed your Jekyll based blog in a GitHub repository. As soon as anything is committed to the repository, GitHub Pages automatically (re-)generates the site and makes it available at a subdomain of github.io. GitHub supports a primary site and sites per repository as well as connecting custom domains.

GitHub Pages is a very natural choice for hosting your static blog because it integrated very tightly with GitHub and your repository.

Primary Site

The primary site is generated from the repository called github_username.github.io, for example the Jekyll directory structure for my blog is stored in a repository called nicholasdille.github.io. GitHub Pages assumes that you are using the master branch for content ready for publishing.

The following screenshot shows what my repository for this blog looks like:

GitHub Repository nicholasdille.github.io

Feel free to browse the repository for my blog and learn from it. Note that I am planning more posts in series one of which will provide a deep dive into customizing the blog.

Project Sites

In addition to the primary site, GitHub allows project specific sites to be hosted on GitHub Pages. Such a site is stored in the same repository as the project itself but in a branch called gh-pages. The site resulting from this branch is published at http://github_username.github.io/repository_name.

Custom Domains

In addition to providing the tool chain for automatically generating the static site from your repository, GitHub Pages also supports connecting custom domains. There are several options which are documented in the help pages. I decided to connect the apex domain (dille.name) as well as the www subdomain. One requirement is creating a file called CNAME located in the root of the repository:

CNAME file for dille.name

When connecting a custom domain, GitHub Pages accepts connections for those domains. For my setup, the CNAME file must contain the apex domain. As soon as this file exists, connecting to the github.io domain redirects to the domain contained in the CNAME file.

The documentation for GitHub Pages contains detailed instructions how to configure the DNS server authorative for your domain. In the end it boils down to creating CNAME records to your github.io domain. In my case I created a CNAME record for dille.name pointing to nicholasdille.github.io. The following screenshot shows the DNS reply for dille.name:

Resolve-DnsName -Name dille.name -DnsOnly

Next Steps

In the next part, I will present an alternative to GitHub Pages by hosting on Azure Websites.

Feedback is always welcome! If you'd like to get in touch with me concerning the contents of this article, please use Twitter.