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
Create in you repo a CNAME file and insert the same domain name
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
Domain | TTL | Type | Target |
covid19trackerita.it. | 0 | A | 185.199.108.153 |
covid19trackerita.it. | 0 | A | 185.199.109.153 |
covid19trackerita.it. | 0 | A | 185.199.110.153 |
covid19trackerita.it. | 0 | A | 185.199.111.153 |
covid19trackerita.it. | 0 | CNAME | polilluminato.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!