diff --git a/news/changelog-1.8.md b/news/changelog-1.8.md index 538092baf65..b108aa75135 100644 --- a/news/changelog-1.8.md +++ b/news/changelog-1.8.md @@ -52,6 +52,7 @@ All changes included in 1.8: - ([#12551](https://github.com/quarto-dev/quarto-cli/pull/12551)): Improve warning issued when `aliases` would overwrite an existing document. - ([#12616](https://github.com/quarto-dev/quarto-cli/issues/12616)): find SVG images in image discovery for listings. - ([#12693](https://github.com/quarto-dev/quarto-cli/issues/12693)): Prevent resource exhaustion on large websites by serializing `NotebookContext` information to file instead of the environment. +- ([#12949](https://github.com/quarto-dev/quarto-cli/issues/12949)): Ensure redirects preserve `hash` and `search` when possible. ## Crossrefs diff --git a/src/resources/projects/website/templates/redirect-map.ejs b/src/resources/projects/website/templates/redirect-map.ejs index 161876c647e..918d0dd7c79 100644 --- a/src/resources/projects/website/templates/redirect-map.ejs +++ b/src/resources/projects/website/templates/redirect-map.ejs @@ -7,6 +7,10 @@ var hash = window.location.hash.startsWith('#') ? window.location.hash.slice(1) : window.location.hash; var redirect = redirects[hash] || redirects[""] || "/"; window.document.title = 'Redirect to ' + redirect; + if (!redirects[hash]) { + redirect = redirect + window.location.hash; + } + redirect = redirect + window.location.search; window.location.replace(redirect);