From 7bc5ee071061ff4285ce6c23b0b64639314d780c Mon Sep 17 00:00:00 2001 From: Brian Pursley Date: Tue, 21 Jul 2020 10:46:33 -0400 Subject: [PATCH] Preserve relative path when switching between versions of the documentation --- layouts/404.html | 1 + layouts/partials/handle-version-switch-404.html | 11 +++++++++++ layouts/partials/navbar-version-selector.html | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/handle-version-switch-404.html diff --git a/layouts/404.html b/layouts/404.html index d3637af38e..5b18c48491 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,4 +1,5 @@ {{ define "main" }} +{{ partial "handle-version-switch-404.html" . }}

Perhaps you were looking for: diff --git a/layouts/partials/handle-version-switch-404.html b/layouts/partials/handle-version-switch-404.html new file mode 100644 index 0000000000..d2130bf49f --- /dev/null +++ b/layouts/partials/handle-version-switch-404.html @@ -0,0 +1,11 @@ +{{/* +If a 404 occurs and the referrer is a different version of the Kubernetes documentation, +don't show the regular 404 error page, but instead redirect to the site root +*/}} + diff --git a/layouts/partials/navbar-version-selector.html b/layouts/partials/navbar-version-selector.html index 09e872053f..ce38b96d9e 100644 --- a/layouts/partials/navbar-version-selector.html +++ b/layouts/partials/navbar-version-selector.html @@ -2,7 +2,8 @@ {{ T "version_menu" }} \ No newline at end of file