How to publish your GitHub pages on a domain

Photo by Igor Miske on Unsplash

Publishing your GitHub pages is a two step process: you first configure GitHub and then set the DNS.

On GitHub

Now scroll down to find the “GitHub Pages” section. Publish the master branch:

Enabling HTTPS is not mandatory but is strongly suggested.

Specify your custom domain:

Now it’s time to create a special file in the root directory of the site repository, the CNAME file:

This file contains only one text row, specifying the pointing domain:

mysite.com

On DNS management

In your DNS management interface (I will refer to Aruba provider), add the following A records (as stated in this help page on GitHub), without specifying an host name:

185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153

If the www host is defined in A record, remove it, because you are going to add it as CNAME record.

Now on with CNAME records. Add a www host, pointing to <mysite>.github.io. (replace <mysite> with the real name of your repository name): don’t forget to add the dot (.) at the end of the hostname!

If everything is ok, you should see a green banner in the Setting section of the published repository.

Please allow some hour to DNS to propagate and enjoy your website!

Bonus track: adding a subdomain

blog.mysite.com

In your DNS management interface, create another CNAME record with “blog” as hostname and pointing again to <mysite>.github.io. (dot included!)

GitHub will take care to publish the correct repository on the corresponding subdomain.

Full-time Human-computer interpreter