From d0b3d8069c5c21251ca258c0300608b1ae0b6c3c Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 6 Dec 2024 23:29:34 +0100 Subject: [PATCH 1/3] 404: be more helpful about outdated versions People used to link to specific versions of manual pages (as reported in https://github.com/git/git-scm.com/issues/1927). Instead of showing a plain 404 page, try to be slightly more helpful by telling the reader that this version no longer exists, providing a link to the newest version. Then, also try to figure out what the most closely-matching page is that _is_ available, and if one is found, show that one, too. Signed-off-by: Johannes Schindelin --- content/404.html | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/content/404.html b/content/404.html index 79772f91c5..954aacda1e 100644 --- a/content/404.html +++ b/content/404.html @@ -7,7 +7,49 @@ }}" alt="404" width="456" height="149" />

That page doesn't exist.

-

+

We recently redesigned the site and older URLs may now lead to missing pages. We apologize for the inconvenience.

+ From dd062e2e9c81b85a2f3da7d87dc7e79715c35b6a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 6 Dec 2024 23:57:05 +0100 Subject: [PATCH 2/3] 404: avoid bogus links to non-existing pages It is theoretically possible that a Git command no longer exists and therefore is no longer documented, either, yet there are links out there pointing to said documentation. Let's try to be somewhat helpful by detecting that situation and directing the reader to the top-level documentation page. Signed-off-by: Johannes Schindelin --- content/404.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/content/404.html b/content/404.html index 954aacda1e..6fd480fc0d 100644 --- a/content/404.html +++ b/content/404.html @@ -25,6 +25,12 @@

That page doesn't exist.

(async () => { // fetch the newest version to obtain the list of versions const result = await fetch(url) + if (result.status < 200 || result.status >= 300) { + el.innerHTML = `The page ${command} does not exist in ${versions[i]}.` })().catch(console.error) } + + match = window.location.pathname.match(/^(.*\/book\/([^/]*))(\/.*)$/) + if (match) { + const [, path, rest] = match + + const el = document.querySelector('#explanation') + el.innerHTML = `This book page was not found. The book's front page is here.` + }