This article goes through the process of setting up a custom domain for a github pages website.

Pre requisites

This article assumes that you already have a github pages website up and running. Mine is klugjo.github.io.

Create the github CNAME file

In order to use a custom domain, you need to let Github know about it with the help of a CNAME file:

  • Create a file names CNAME at the root of your website. The file name has to be all Caps.
  • Inside that file, input your custom domain name without http(s)://.
    My CNAME file contains:
www.codeblocq.com
  • Commit and push your changes

That is it for the configuration on the github side.

Setup the DNS provider

You can contact your DNS provider for help on how to configure an A record but this is how I configured mine:

DNS provider configuration github pages custom domain

The CNAME record for www is set to klugjo.github.io. The role of a CNAME record is to map a name to another name. Useful when the IP address of the host is not know or not stable.

The URL record is set to http://www.codeblocq.com in order to redirect all traffic to the www site.

Notes