Custom domains with Github pages

Yonatan Miller
2 min readJan 13, 2019

--

Github and EFF’s Lets Encrypt offer free HTTPS encryption for custom domains on their GitHub-pages (along with Cloudfare backed CDNs) an attractive solution for static pages.

Logo of “Let’s Encrypt” with a logo that looks like a lock with sunrise above it

I have two different Github repositories and want each of them to have their own unique domain. The way Github pages works, your user/organization Github page will be https://acountName.github.io and subsequent repositories (considered projects) will be a sub route, namely htpps://acountName.github.io/repositoryName

github.com/shushugah/shushugah.github.io => shushugah.github.io

github.com/shushugah/23. => shushugah.github.io/23

I purchased two custom domains from NameCheap, shushugah.com and 2Jews3Opinions.com. I created CNAME file for each repository with the custom domains in each and inside NameCheap advanced DNS settings I configured them to point to Github’s IP addresses. Note how both custom domains share the same CNAME Record below?

A Records with values ranging from 185.199.108.153–185.199.111.153 and CNAME Record value of shushugah.github.io

This leads to a side affect where shushugah.com correctly routes, but shushugah.com/23 redirects to 2Jews3Opinions.com because the github.com/shushugah/23 is treated as a sub route.

As a last step, make sure Github forces the usage of HTTPS everywhere. This setting can be found in github.com/username/repo/settings

Screenshot of settings panel for each Github repository

I am uncertain at this point, if this is an acceptable bug. Everytime I add a repository to GithubPages, I have to blacklist repo name from valid routes in my primary domain, shushugah.com. If I had a repository named about this could lead to errors and SEO issues. An Nginx configuration could prevent this kind of issue. 🤔

--

--

Yonatan Miller

Programmer 💻🔥 Articles are my own, sorta ☕ Writing for pleasure and advocacy.