aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorValentin Gagarin <valentin.gagarin@tweag.io>2023-11-27 08:33:03 +0100
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2023-11-27 13:29:00 +0000
commit8fb477a6e7ecb887761b73d4defeb75fca99e59c (patch)
treeca8412fcfd619e69d85a7470f21d706c6599f867 /doc
parent05b7e2dc576fd7ba30a5efc8a1ef708bba52128f (diff)
add path based redirects
up to now, those were managed outside of this repo, which as unsurprisingly a real hassle to deal with if one wanted to prevent URLs from breaking when moving pages around. this change removes a large part of the friction involved in moving content in the Nix manual. possible next steps for further automation: - check for content that moved and warn if it's not reachable from links that were valid prior to a change - create redirect rules automatically based on this information (cherry picked from commit 2b7016cc56d12e67de9f1f25b18311866a26a5fe)
Diffstat (limited to 'doc')
-rw-r--r--doc/manual/_redirects30
-rw-r--r--doc/manual/redirects.js8
2 files changed, 35 insertions, 3 deletions
diff --git a/doc/manual/_redirects b/doc/manual/_redirects
new file mode 100644
index 000000000..4ea289d86
--- /dev/null
+++ b/doc/manual/_redirects
@@ -0,0 +1,30 @@
+# redirect rules for paths (server-side) to prevent link rot.
+# see ./redirects.js for redirects based on URL fragments (client-side)
+#
+# concrete user story this supports:
+# - user finds URL to the manual for Nix x.y
+# - Nix x.z (z > y) is the most recent release
+# - updating the version in the URL will show the right thing
+#
+# format documentation:
+# - https://docs.netlify.com/routing/redirects/#syntax-for-the-redirects-file
+# - https://docs.netlify.com/routing/redirects/redirect-options/
+#
+# conventions:
+# - always force (<CODE>!) since this allows re-using file names
+# - group related paths to ease readability
+# - always append new redirects to the end of the file
+# - redirects that should have been there but are missing can be inserted where they belong
+
+/expressions/expression-language /language/ 301!
+/expressions/language-values /language/values 301!
+/expressions/language-constructs /language/constructs 301!
+/expressions/language-operators /language/operators 301!
+/expressions/* /language/:splat 301!
+
+/package-management/basic-package-mgmt /command-ref/nix-env 301!
+
+/package-management/channels* /command-ref/nix-channel 301!
+
+/package-management/s3-substituter* /command-ref/new-cli/nix3-help-stores#s3-binary-cache-store 301!
+
diff --git a/doc/manual/redirects.js b/doc/manual/redirects.js
index b43622ed6..2ff446cdd 100644
--- a/doc/manual/redirects.js
+++ b/doc/manual/redirects.js
@@ -1,7 +1,9 @@
-// redirect rules for anchors ensure backwards compatibility of URLs.
-// this must be done on the client side, as web servers do not see the anchor part of the URL.
+// redirect rules for URL fragments (client-side) to prevent link rot.
+// this must be done on the client side, as web servers do not see the fragment part of the URL.
+// it will only work with JavaScript enabled in the browser, but this is the best we can do here.
+// see ./_redirects for path redirects (client-side)
-// redirections are declared as follows:
+// redirects are declared as follows:
// each entry has as its key a path matching the requested URL path, relative to the mdBook document root.
//
// IMPORTANT: it must specify the full path with file name and suffix