GitHub Pages 404.html Can Read the Deep Link

GitHub Pages can serve a custom 404.html for a path such as /note/123 without changing the address bar. The fallback page can read the requested path and pass the note ID to the single-page app:

const match = window.location.pathname.match(/^\/note\/([^/]+)\/?$/);
const noteId = match?.[1] ?? null;

This lets a static app display the requested note, but the original HTTP response is still 404. A host or edge rewrite is needed for the same clean URL to return HTTP 200.

Comments

  1. Markdown is allowed. HTML tags allowed: <strong>, <em>, <blockquote>, <code>, <pre>, <a>.