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.


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.


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


List of A records to create:


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.


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


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.


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