URL Aliases

A post has one canonical slug — the filename. Everything else is an alias.

shortSlug: tube is a forward alias: human-friendly, shareable, intentional. redirectFrom: /posts/old-slug is a backward alias: history-preserving, automatic, invisible to the reader.

Both are the same thing. Both live in the frontmatter. Both generate CloudFront redirect rules at build time. The post declares all the URLs it answers to; the build wires them up.

The alternative is an external redirect table — a config file somewhere, a database row, a DNS entry managed separately from the content. Those drift. They go stale. Nobody knows which ones are still valid.

If the redirect lives in the post file, it goes away when the post goes away. It's version-controlled with the content. The git log shows when the slug changed and what it was before.

The unified model

shortSlug: tube # /t/tube → canonical
redirectFrom:
  - /posts/the-post-is-the-spec # old slug → canonical

One pass at build time. One CloudFront function. All aliases resolved.

The journey

prev: designers-dont-know-git, short-urls-in-frontmatter next: site-map-is-a-graph Came directly from renaming designers-dont-know-git the same day it was written. The slug changed, the old URL needed to keep working, and the fix turned out to be the same mechanism as shortSlug — just pointing backward instead of sideways. short-urls-in-frontmatter started the alias idea; this post generalizes it.