DEV Community

loading...
Cover image for How to redirect your hosted GitHub page to a custom domain

How to redirect your hosted GitHub page to a custom domain

Christine Kim
Teach me internet!
Updated on ・2 min read

If you have your own domain, and a Github account, you could take advantage of redirecting hosted pages to your own domain.

This article is assuming that you already deployed your GitHub page at yourUsername.github.io

For example, I have a website www.example.com through Google Domains. Below is a screen shot of my custom domain.
Screen Shot 2021-06-04 at 10.33.04 PM

To point your GitHub page to your website, first add to your DNS records the url, CNAME record, and the IP addresses. CNAME means that it's a Custom Domain.

www , CNAME, and 'yourGitHubUsername'.github.io .

Next, add GitHub's IP addresses under the DNS - with an A record. The A indicates that it's an 'Alias'.
As of June 2021, the IPs are

185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
Enter fullscreen mode Exit fullscreen mode

@ , A , and the above IP addresses.
You can double check here.

Lastly, under the Settings tab on your GitHub repo for your site, go to the Pages section.
In the custom domain field, put your custom domain (www.example.com).
It might take a little time for it to load
Congrats, you are now pointing your page to your custom domain!

You can also host pages.
By deploying through Github pages, that are not username.github.io. If you deploy using gh pages, you can add themto your DNS configuration.

For example, if I had www.mywebsite.com, and deployed a page www.mywebsite.com/books
add into your DNS configuration
books , CNAME, and 'yourGitHubUsername'.github.io .

Discussion (0)