parallax

GitHub Pages Custom Domain and Https
Tech

GitHub pages are great, https is great, and custom domain is great. But when combining them together, I was having a hard time going through all their manuals to make them work. What I want is simple, to bind my domain (weili.me) with my github pages (weilinear.github.io), and add two subdomains, www will work the same as weili.me, and blog will point to my blog (weilinear.github.io/blog).

An overly simple mental model for custom domain is that that domain is an alias for the actual github page. For example, weili.me ⇒ weilinear.github.io. What it achieves that is through the Custom domain setting in Pages, and under the hood is the CNAME file (e.g. https://github.com/weilinear/weilinear.github.io/blob/master/CNAME). Github page server will figure out which is the right content to show based on the URL it gets as it has those CNAMEs associated with each Github pages.

Here is the less simple if-else condition for APEX domain and subdomains:

Https have a third requirements, the site couldn’t contain any thing other than A/CNAME records. Those URL redirects won’t work.

Therefore, for my simple site, the following will work when configuring the DNS

TypeHostValueTTL
A Record@185.199.108.153Automatic
CNAME Recordblogweilinear.github.io.Automatic
CNAME Recordwwwweilinear.github.io.Automatic

On Github side,

RepoCustom Domain
https://github.com/weilinear/weili.me
https://github.com/weilinear/blogblog.weili.me

Sign up for the newsletter

Enter an e-mail address to test out form validation and Flowbite modal via reactive Svelte components. This form does not collect any data.