Setting up a custom subdomain for a GitHub Pages site

This is so much easier than I was expecting it to be.

I launched my new Datasette Lite project (background) using GitHub Pages - originally hosted here:

Shortly after launching I realized that the project deserved its own vanity subdomain. I wanted to use for this.

GitHub Pages makes this really easy.

I started by pointing the CNAME for at - I use Vercel for the DNS for that domain, so I set this up in their interface.

Then I used the Pages tab in the "settings" interface for the GitHub repository and told it about my new domain.

GitHub wrote a file called CNAME directly into the root of my repository for me containing just

This started working over HTTP straight away - it took a few more minutes for the Lets Encrypt certificate to be issued for it, at which point started working too.

I then used the "Enforce HTTPS" option to ensure any hits to http://... were redirected to https://

Screenshot of the GitHub interface for setting the domain, showing the Enforce HTTPS checkbox


GitHub Pages set up redirects from the old site to the new one without me even asking them to.

The redirects preserve both query string parameters AND fragment hashes, which means that this old URL continues to work after the move:

It redirects to:

Created 2022-05-04T15:25:38-07:00, updated 2022-08-16T22:11:30-07:00 · History · Edit