Custom domains with Github pages

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.

Image for post
Image for post
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?

Image for post
Image for post
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

Image for post
Image for post
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. 🤔

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store