Browsers implement URI fragments (#fragment) as a link to an element on the page with a matching id. Many sites use this for a table of contents and/or self-referential headers.
Strangely, browsers are still missing a way to handle the linked id being moved without JavaScript.
Conversation
URI fragments aren't sent to the server, so it can't be done with a server-side redirect.
For the GrapheneOS site, we care a great deal about not breaking links, so we implement this with JavaScript using a Map of all the necessary client-side redirects:
1
4
There was a proposal to handle this without needing JavaScript:
w3.org/People/Bos/red
It would allow you to set up these redirects with structured metadata:
<link rel="redirect" id="old-section" href="new-location#new-section">
I hope someone picks this up and gets it done.
