Skip to content

layouts: adopt git-scm.com's alias template to preserve query strings and anchors#87

Open
dscho wants to merge 1 commit intomainfrom
custom-alias-layout
Open

layouts: adopt git-scm.com's alias template to preserve query strings and anchors#87
dscho wants to merge 1 commit intomainfrom
custom-alias-layout

Conversation

@dscho
Copy link
Member

@dscho dscho commented Feb 25, 2026

Hugo's built-in alias pages use a bare <meta http-equiv="refresh"> redirect, which discards any query string or URL fragment from the original request. This means that if someone follows a link like https://gitforwindows.org/FAQ.html#some-heading, the redirect to faq.html loses the #some-heading anchor.

This adopts the custom alias.html layout from git-scm.com, which enhances the redirect with JavaScript that appends window.location.search and window.location.hash to the redirect target. The <meta http-equiv="refresh"> remains as a no-JavaScript fallback (which still loses query strings and anchors, but at least lands on the right page).

…nchors

Hugo's built-in alias pages use a bare <meta http-equiv="refresh"> tag,
which discards any query string or URL fragment from the original
request. This is a problem when external links point to specific
anchors on pages that have since been renamed.

Adopt the custom alias.html layout from git-scm.com, which enhances
the redirect with JavaScript that appends window.location.search and
window.location.hash to the redirect target. The <meta http-equiv=
"refresh"> remains as a fallback for browsers with JavaScript disabled
(which will still lose query strings and anchors, but at least land on
the right page).

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant