Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

Docs: use 404.html to redirect versionless docs pages to latest/

Louis Choquelb892a917799e
diff --git a/Makefile b/Makefile
index 888809fb7..7a8e7f3e5 100644
--- a/Makefile
+++ b/Makefile
@@ -104,6 +104,7 @@ make docs-list - List deployed documentation versions
make docs-deploy VERSION=x.y.z - Deploy docs as version x.y.z (local, no push)
make docs-deploy-stable - Deploy stable docs with 'latest' alias (CI only)
make docs-deploy-beta - Manually deploy pre-release docs with '-beta' suffix
+make docs-deploy-404 - Deploy 404.html for versionless URL redirects
make check - Shorthand -> format lint mypy
make c - Shorthand -> check
@@ -128,7 +129,8 @@ export HELP
merge-check-ruff-lint merge-check-ruff-format merge-check-mypy merge-check-pyright \
li check-unused-imports fix-unused-imports check-uv check-TODOs \
docs docs-check docs-serve-versioned docs-list docs-deploy docs-deploy-stable docs-deploy-beta \
- test-count check-test-badge
+ test-count check-test-badge \
+ docs-deploy-404
all help:
@echo "$$HELP"
@@ -557,15 +559,27 @@ docs-deploy: env
$(call PRINT_TITLE,"Deploying documentation version $(if $(VERSION),$(VERSION),$(DOCS_VERSION))")
$(VENV_MIKE) deploy $(if $(VERSION),$(VERSION),$(DOCS_VERSION))
-docs-deploy-stable: env
+docs-deploy-stable: env docs-deploy-404
$(call PRINT_TITLE,"Deploying stable documentation $(DOCS_VERSION) with latest alias")
$(VENV_MIKE) deploy --push --update-aliases $(DOCS_VERSION) latest
$(VENV_MIKE) set-default --push latest
-docs-deploy-beta: env
+docs-deploy-beta: env docs-deploy-404
$(call PRINT_TITLE,"Deploying pre-release documentation $(DOCS_VERSION)-beta")
$(VENV_MIKE) deploy --push $(DOCS_VERSION)-beta
+docs-deploy-404:
+ $(call PRINT_TITLE,"Deploying 404.html to gh-pages root for versionless URL redirects")
+ @TMPDIR=$$(mktemp -d) && \
+ git worktree add "$$TMPDIR" gh-pages && \
+ cp docs/404.html "$$TMPDIR/404.html" && \
+ cd "$$TMPDIR" && \
+ git add 404.html && \
+ git diff --cached --quiet || git commit -m "Update 404.html for versionless URL redirects" && \
+ git push origin gh-pages && \
+ cd - > /dev/null && \
+ git worktree remove "$$TMPDIR"
+
##########################################################################################
### SHORTHANDS
##########################################################################################
diff --git a/docs/404.html b/docs/404.html
new file mode 100644
index 000000000..3108b771a
--- /dev/null
+++ b/docs/404.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Redirecting...</title>
+ <script>
+ const path = window.location.pathname;
+ // Get the first path segment (e.g., "/latest/foo/bar" → "latest")
+ const firstSegment = path.split('/').filter(seg => seg)[0];
+
+ // Check if it's a version: either "latest" or starts with "0." (e.g., "0.17")
+ const hasVersion = firstSegment === 'latest' || (firstSegment && firstSegment.startsWith('0.'));
+
+ if (!hasVersion) {
+ // No version in URL, redirect to /latest/...
+ const newUrl = '/latest' + path + window.location.search + window.location.hash;
+ window.location.replace(newUrl);
+ } else {
+ // Already has version, this is a real 404
+ document.write('<h1>Page not found</h1><p>The page you requested does not exist.</p>');
+ }
+ </script>
+</head>
+<body>
+ <noscript>
+ <h1>Page not found</h1>
+ <p>Enable JavaScript for automatic redirects, or go to <a href="/latest/">the documentation</a>.</p>
+ </noscript>
+</body>
+</html>