CARVIEW |
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:
https://simonw.github.io/datasette-lite/
Shortly after launching I realized that the project deserved its own vanity subdomain. I wanted to use lite.datasette.io
for this.
GitHub Pages makes this really easy.
I started by pointing the CNAME
for lite.datasette.io
at simonw.github.io
- 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 lite.datasette.io
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 https://lite.datasette.io/ started working too.
I then used the "Enforce HTTPS" option to ensure any hits to https://...
were redirected to https://
Redirects
GitHub Pages set up redirects from the old https://simonw.github.io/datasette-lite/ 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:
https://simonw.github.io/datasette-lite/#/fixtures?sql=select+sqlite_version%28%29
It redirects to:
https://lite.datasette.io/#/fixtures?sql=select+sqlite_version%28%29
Related
- readthedocs Pointing a custom subdomain at Read the Docs - 2020-08-14
- fly Assigning a custom subdomain to a Fly app - 2021-11-20
- github-actions Serving a JavaScript project built using Vite from GitHub Pages - 2023-10-23
- github GitHub Pages: The Missing Manual - 2022-10-31
- datasette Redirects for Datasette - 2020-11-25
- readthedocs Promoting the stable version of the documentation using rel=canonical - 2022-01-20
- npm Publishing a Web Component to npm - 2021-11-28
- datasette Scraping Reddit and writing data to the Datasette write API - 2023-03-13
- cloudflare How to get Cloudflare to cache HTML - 2024-01-08
- cloudflare Redirecting a whole domain with Cloudflare - 2024-03-15
Created 2022-05-04T15:25:38-07:00, updated 2022-08-16T22:11:30-07:00 · History · Edit