Home How to setup github pages with an https custom domain?
Post
Cancel

How to setup github pages with an https custom domain?

Github pages is one of the simplest ways to blog, or to have a simple static site. However, routing your own domain to Github pages can be tricky. It is mostly a matter of correct configurations and patience. You need first to configure your domain or sub-domain to point to Github and then configure Github to recognize the routing. Finally, setting up HTTPS, which should work by just checking a single checkbox, but when it doesn’t, it is tough to know what to do next.

DNS configurations

Domain

In your domain providers’ DNS management page create new A Records. Set the value of the A record to @ and point it to the following IP addresses.

  • 185.199.108.153
  • 185.199.109.153
  • 185.199.110.153
  • 185.199.111.153

godaddy-github-domain.png Setting up an A record on GoDaddy

Sub-domain

Setting up a sub-domain is rather easy. Just create a CNAME file in your repository root. The file should include your sub-domain, for example, sub-domain.mfarag.com. In your domain providers’ DNS management page create a new CNAME record. The record should refer to username.github.com in my case that was muhammadfarag.github.com.

godaddy-github-sub-domain-cname.png Setting up a CNAME record on GoDaddy

GitHub pages configurations

godaddy-github-sub-domain-cname.png

Under your repository settings, you will find a GitHub Pages section. All you need to do is to select what will be the source of the pages to serve. You can either select either master or gh-pages branches if they exist, or docs directory under your master branch.

Once you selected your page source, you have enabled your GitHub pages. The configuration section will show you the default URL which should be https://username.github.io/repo-name. Now we get to the tricky part. enforcing https.

If you are using a sub-domain to route the traffic to, you should be able to select the checkbox and things should work like a charm. If not, check trouble-shooting https section.

Troubleshooting Https.

  • If you are routing a domain, you will need to make sure that you are using the four IPs in the domain section.
  • My website is over https, but the browser shows something is missed up with the certificate
    • Give it time, sometimes it could take up to a couple of hours before things work properly. The https certificate might still be pointing to github.io instead of your domain.
  • When all has failed: Github responds to inquiries relatively quickly, within a day. Go to their contact us page.

Resources

This post is licensed under CC BY 4.0 by the author.
Contents

Type Classes

Github Pages, Markdown and Jekyll tips and tricks

Comments powered by Disqus.