Set up custom domain name with GitHub pages


The whole process for various situations is described in GitHub documentation. This is just a reminder for myself how to properly configure top-level apex domain redirect with GitHub Pages.

All of your <username> or <orgname> pages will be redirected to the new custom domain, so your project pages can benefit from this automatically. If you already have a project page like <username>, this will become <custom.domain>/projectname.

Sequence of actions

Let’s say you own for the sake of example, and your github username is yourname.

On GitHub

Create a repository with name <username> or <orgname> depending on the repo type.

Create a repo add a file called CNAME with the following contents to the root directory:

If you prefer the name with www prefix, put it at the top. Commit and push. That’s it with github.

At DNS provider config

Add an A record:

name: @
type: A
TTL : 1h
data: [,,,]

Add a CNAME record:

name: www
type: CNAME
TTL : 1h

With this looks like the following:


It might take several hours for the information to propagate throughout the net and become accessible everywhere.