Full guideline for using custom domain to any github repository. If you are looking for a way to publish / point / redirect your github repository to your own custom domain, this solution is for you.

  • If you find different github features due to github site update, we suggest you to find the same features from the settings and follow these steps accordingly. It will work fine.

Step 1

Open your repositoy and click on Settings

Repo

Step 2

Under the Github Pages -> Source, click on None, then select master or another branch, then Save it

Select Page Branch

This will publish your project with github-pages via selected branch. So, your site is live now at https://username.github.io/projectname. Now we will set custom domain to our github project. But before that we will edit our main domain DNS configuration. Who already have a branch published will skip the step 2.

Step 3

Add / point the following IP addresses to your custom domain in DNS zone with A record

  • 185.199.108.153
  • 185.199.109.153
  • 185.199.110.153
  • 185.199.111.153

Open DNS zone
dns-zone

Then add the ips
add-github-ips

Step 4

Come back to your repository Settings-> Github Pages, then put your domain name to this field and click on Save

Put your domain name

Step 5 (fix https issue and review)

After the step 4, your github page will be published with your custom domain name. When you'll visit github project link like https://tradecoder.github.io/github-custom-domain-config and when you'll visit your custom domain like https://tradecoder.com, for both the cases it will load with your custom domain name. It may take few minutes to get effective.

And if you find in the section of Github Pages that https is not active, it may take upto 24 hours to be active. If not, you may have to remove and add the domain in the github page again.
force-https

If you find this solution helpful, please feel free to share this with your network.