Using custom domain for GitHub pages

Hossain Khan
Jan 19, 2018 · 2 min read

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

Here are some of the key steps to setup your GitHub pages enabled project to use custom domain.


⚙️Step 1 — Set domain in GitHub project

Go to your GitHub Pages site’s repository settings. Under “Custom domain”, add or remove your custom domain and click “Save”.

Setting “custom domain” creates a file named 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). All you need to do is set & records for the selected domain.

This is a sample screenshot taken from Google Domains portal.

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

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


That’s it, both and will go to your selected GitHub pages site. If you want to see a live example, you may visit my portfolio “hossainkhan.com” hosted via GitHub pages ✌️.

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

Hossain Khan

Written by

Passionate Android developer and curious tinkerer! https://hossainkhan.com/