Using custom domain for GitHub pages

Recently I decided to host my personal portfolio site using GitHub pages. Even though they have very detailed instruction on how to setup a custom domain, I found it cumbersome to get to the right information. 🙄

Here are 2 key steps to setup your GitHub pages enabled project to use your custom domain.

⚙️Step 1 — Set domain in GitHub project

Setting “custom domain” creates a file named CNAME in the same repository. Don’t delete it.

⚙️Step 2 — Set custom resource record for domain

This step is specific to your domain name register (like GoDaddy,, Google Domains, etc). All you need to do is set A & CNAME records for the selected domain.

For A record, set,, and To redirect www subdomain to the original domain, add a CNAME record with your GitHub pages profile URL with a .(dot) in the end, for example, ‘’.

Official References: For most up to date IP Addresses, use GitHub’s official documentation and for setting up CNAME use this documentation.

That’s it, both and will now go to your selected GitHub pages site (may need to wait up to 24 hours). If you want to see a live example, you may visit my portfolio “” hosted via GitHub pages repository ✌️.

UPDATE #1: The IP addresses for DNS A record is updated. The new IP addresses are required to use the free HTTPS support for GitHub pages.

UPDATE #2: Some people said this change is not working, it is actually because the DNS update can take upto 24 hours to propagate. So, I guess try hitting your domain next day 🤓

NOTE #1: Even though it’s very obvious, you should replace YOUR-GITHUB-USERNAME and with your personal github username and domain name you are trying to use respectively.

Written by

Passionate Android developer and curious tinkerer!🤖 Knowledge is power🦸! Share freely!📚

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store