How to add a custom domain to a GitHub Page

How to add a custom domain to a GitHub Page

ยท

2 min read

Hi everyone, in this article I want to show you how to add a custom domain to a GitHub Page when you want to level up your (side)project with a domain name. I discovered these steps last week when I register a domain for one of my sideproject which is hosted on a GitHub Page, some steps are related to GitHub others to your domain and in particular the DNS.

GitHub Configuration

In your GitHub repo go to the Settings tab, scroll down until you reach GitHub Pages -> Custom domain, and insert here your custom domain name, in my case it's covid19trackerita.it

custom_domain_github.png

Create in you repo a CNAME file and insert the same domain name

cname_github_page_custom_domain.png

Domain Configuration

On your domain provider, you have to change some configuration about your DNS. You have to create four A records and one CNAME record

DomainTTLTypeTarget
covid19trackerita.it.0A185.199.108.153
covid19trackerita.it.0A185.199.109.153
covid19trackerita.it.0A185.199.110.153
covid19trackerita.it.0A185.199.111.153
covid19trackerita.it.0CNAMEpolilluminato.github.io.

The dot at the end of all domain names is mandatory otherwise the configuration will not work.

Now you have to wait some hours, at most one day, and you will be able to access your GitHub Page using your custom domain.

Bonus Tip

When all it's OK you can also add an SSL Certificate to your web page, in your GitHub repo go to the Settings tab, scroll down until you reach GitHub Pages -> Enforce HTTPS and enable it!

Simple, isn't it? Alberto

Did you find this article valuable?

Support Alberto Bonacina by becoming a sponsor. Any amount is appreciated!