aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorJohn Olheiser <john.olheiser@gmail.com>2023-04-28 15:51:17 -0500
committerGitHub <noreply@github.com>2023-04-28 15:51:17 -0500
commitbc784a705bc5a49ddb3ceffe1ef1205fd15f0c08 (patch)
tree0ab880a2395b69cc309ae8e7dd5b41e3da027361 /docs
parent3843252938e55b0e769d2291afea73242e255b1b (diff)
downloadgitea-bc784a705bc5a49ddb3ceffe1ef1205fd15f0c08.tar.gz
gitea-bc784a705bc5a49ddb3ceffe1ef1205fd15f0c08.zip
Override alias template to preserve anchor fragment (#24394)
This PR fixes an annoyance where docs aliases aren't preserving their anchor fragments. The refactor included aliases to keep old links from dying, but currently they redirect without their anchor, which was used _often_ to jump to sections. This overrides the alias template with an alternative that preserves the anchor fragment. To note, this is just a copy of the [embedded template](https://github.com/gohugoio/hugo/blob/5c7b79cf7f00aa2651dd5f0364ee575af6715a31/tpl/tplimpl/embedded/templates/alias.html), but defaults to a JS redirect that preserves the anchor, and uses the meta tag as a fallback for noscript users. --------- Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/layouts/alias.html13
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/layouts/alias.html b/docs/layouts/alias.html
new file mode 100644
index 0000000000..b96cb34219
--- /dev/null
+++ b/docs/layouts/alias.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html{{ with site.LanguageCode | default site.Language.Lang }} lang="{{ . }}"{{ end }}>
+ <head>
+ <meta charset="utf-8">
+ <title>{{ .Permalink }}</title>
+ <link rel="canonical" href="{{ .Permalink }}">
+ <meta name="robots" content="noindex">
+ <noscript><meta http-equiv="refresh" content="0; url={{ .Permalink }}"></noscript>
+ <script>
+ window.location = "{{ .Permalink }}" + window.location.search + window.location.hash;
+ </script>
+ </head>
+</html>