diff --git a/README.md b/README.md index 7c74feb..30771df 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ the Ecosystem section of the new landing page. | `commit-check.github.io/getting-started/` | [commit-check.com/getting-started/](https://commit-check.com/getting-started/) | | `commit-check.github.io/blog/…` | [commit-check.com/blog/…](https://commit-check.com/blog/) — same paths | | `commit-check.github.io/projects/` | [commit-check.com/](https://commit-check.com/) | +| `commit-check.github.io/commit-check/.html` — the Sphinx docs up to v2.12 | the matching page, e.g. `configuration.html` → [/configuration/](https://commit-check.com/configuration/), `cli_args.html` → [/configuration/#command-line-arguments](https://commit-check.com/configuration/#command-line-arguments) | The redirects are generated by `scripts/build_redirects.py`, and `tests/` verifies the map still covers every URL the old site served. GitHub Pages has diff --git a/netlify.toml b/netlify.toml index b404d62..fab0c1a 100644 --- a/netlify.toml +++ b/netlify.toml @@ -24,6 +24,57 @@ status = 301 force = true +# The Sphinx project docs that predate the mkdocs site (OLD_PROJECT_DOCS in +# scripts/build_redirects.py). Anything else under /commit-check/ was an index +# or README page, which the home page replaced. +[[redirects]] + from = "/commit-check/cli_args.html" + to = "https://commit-check.com/configuration/#command-line-arguments" + status = 301 + force = true + +[[redirects]] + from = "/commit-check/what-is-new.html" + to = "https://commit-check.com/changelog/#v200" + status = 301 + force = true + +[[redirects]] + from = "/commit-check/configuration.html" + to = "https://commit-check.com/configuration/" + status = 301 + force = true + +[[redirects]] + from = "/commit-check/example.html" + to = "https://commit-check.com/example/" + status = 301 + force = true + +[[redirects]] + from = "/commit-check/migration.html" + to = "https://commit-check.com/migration/" + status = 301 + force = true + +[[redirects]] + from = "/commit-check/troubleshoot.html" + to = "https://commit-check.com/troubleshoot/" + status = 301 + force = true + +[[redirects]] + from = "/commit-check/changelog.html" + to = "https://commit-check.com/changelog/" + status = 301 + force = true + +[[redirects]] + from = "/commit-check/*" + to = "https://commit-check.com/" + status = 301 + force = true + # Everything else kept its path on the new site, so the tail is carried across # unchanged. This also covers URLs the stub list does not enumerate. [[redirects]] diff --git a/scripts/build_redirects.py b/scripts/build_redirects.py index e9993d8..e3616c5 100644 --- a/scripts/build_redirects.py +++ b/scripts/build_redirects.py @@ -57,8 +57,33 @@ REDIRECTS = {path: path for path in SAME_PATH} | {"/projects/": "/"} +#: The project documentation that came before the mkdocs site: Sphinx pages the +#: ``commit-check/commit-check`` repository published at +#: ``commit-check.github.io/commit-check/.html``. That project site is no +#: longer published, so GitHub Pages serves those paths from *this* site — and +#: without these they fell through to the 404 fallback and landed every reader +#: on the home page. They are still linked from the README of every release up +#: to v2.12 (and so from PyPI), from blog posts and from the Action's docs. +#: +#: The page list is the Sphinx ``docs/`` of v2.12.2, the last release built +#: that way, plus ``cli_args.html``, which sphinx-argparse generated. Each maps +#: to the page that took over its content; ``what-is-new`` was the v2.0.0 +#: release notes and ``cli_args`` the command-line reference. +OLD_PROJECT_DOCS = { + "/commit-check/": "/", # also serves /commit-check/index.html + "/commit-check/README.html": "/", + "/commit-check/cli_args.html": "/configuration/#command-line-arguments", + "/commit-check/configuration.html": "/configuration/", + "/commit-check/example.html": "/example/", + "/commit-check/migration.html": "/migration/", + "/commit-check/troubleshoot.html": "/troubleshoot/", + "/commit-check/changelog.html": "/changelog/", + "/commit-check/what-is-new.html": "/changelog/#v200", +} + # The fragment is carried across by the script: a reader following a deep link -# into a page should keep their place. ``location.replace`` rather than +# into a page should keep their place — unless the target already names its +# own section, which a second "#" would break. ``location.replace`` rather than # ``location.href`` so the stub does not land in the back-button history and # trap them in a loop between the two sites. TEMPLATE = """ @@ -69,7 +94,7 @@ Moved to commit-check.com - +