Hello!

Today I want to show how you can add custom DNS for the GithubPages site. This requires a few steps. Let’s start with domain name registration. I chose Namecheap to register my domain name. Open Namecheap website and in the search you need to enter the name you want to buy. Once you found what you are looking for and add it to your card.

Namecheap

It says Taken next to my domain name because I already bought it.

Once the domain name is purchased you need to go to your profile and click Manage.

NamecheapDns

In the Advanced DNS section, I will add some records according to the Github documentation. Current addresses can also be found in documentation

Dns

List of A records to create:

  • 185.199.108.153
  • 185.199.109.153
  • 185.199.110.153
  • 185.199.111.153

You also need to create a CNAME that will point to the GitHub Pages url. In my case it is mpostument.github.io.

The next step is to add a file named CNAME to the root of the GitHub Pages repository. In the first line of this file you need to write a new domain name, for me it is mpostument.com. I use a static site generator Hugo with Github Actions (You can read about it in my previous programming). In order for CNAME to get to the root after deployment, it must be placed in the static folder.

CNAME

The last step is to specify a new domain name in the GitHub Pages repository settings. To do this, open the repository and click Settings

Settings

And find the section responsible for GitHub Pages. In the Custom domain field, specify your value and click Save. The Enforce HTTPS option will be available within 24 hours, I recommend that you also enable it.

PagesSetting

And now after going to mpostument.github.io you will be immediately redirected to mpostument.com