From ea9cccb87c8fd2f1465af4d3f4c0b59c3410eea8 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..e02a6d6a78 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 28e57871481c0509b2f27040e1d9891e267321e6 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 e02a6d6a78..7efbea65c7 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.` + }