Repository navigation
docs: Fix libpython Sphinx canonical and sitemap version (#5935) - #7760
Conversation
conf.py set html_baseurl twice. The second assignment (the bare domain root, added for sphinx-sitemap) overwrote the canonical base, so every libpython page emitted a bare-root canonical, and the sitemap scheme injected the full dev version (grass8.6.0dev), producing 404 URLs. Use a single html_baseurl built from the short numbered prefix (https://grass.osgeo.org/grass<MAJOR><MINOR>/manuals/libpython/) and set the sitemap scheme to "{link}", so canonical and sitemap URLs are identical and resolve to the published grass86 tree. Make merge_sitemaps.py preserve each source sitemap's URLs by default (the --version rewrite is now opt-in) and drop the --version override in documentation.yml, so the merged manuals sitemap keeps grass-stable manuals and grass86 libpython URLs. Add a unit test for check_url_version. Drafted with AI assistance.
|
So the build artifact for the merged site now looks correct for the libpython, but the manuals look off. Shouldn't they be grass-devel? <url>
<loc>https://grass.osgeo.org/grass-stable/manuals/command_line_intro.html</loc>
<lastmod>2026-07-18</lastmod>
</url>
<loc>https://grass.osgeo.org/grass86/manuals/libpython/grass.app.html</loc> |
|
Oh, a tricky one! |
|
Development vs stable links: My idea was to keep stable links when absolute URL is needed and replace in CI for dev (not implemented, there is a PR). CI could use relative links. |
Per review feedback (OSGeo#7760): keep the stable manuals tree as the absolute canonical base instead of the numbered grassMAJORMINOR tree. This matches the MkDocs core manuals (site_url = .../grass-stable/manuals/) so the merged sitemap is uniformly grass-stable, and leaves dev-URL rewriting to CI.
|
Agreed on keeping stable as the absolute base. I switched the libpython canonical to https://grass.osgeo.org/grass-stable/manuals/libpython/ so it matches what the MkDocs manuals already do (site_url is grass-stable and isn't overridden per build). Now every version build (grass-devel, grass-stable, and the numbered versions) canonicalizes to grass-stable, and the merged sitemap is uniformly grass-stable instead of the grass-stable/grass86 mix from before. The one case this doesn't fully resolve is the dev tree: a page that's new in 8.6 and not yet in 8.5 will canonical to a grass-stable URL that 404s. I'd rather not fix that by rewriting the canonical for dev, since then dev competes with stable in search again, which is the thing the canonical is there to prevent. The cleaner path is noindex, follow on the whole dev tree (a per-build flag when VERSION ends in dev), applied to both the MkDocs overrides and the Sphinx head so the two stay consistent. That's compatible with the relative-links or CI-rewrite idea, but noindex is the smaller change and avoids putting noindex and a cross-version canonical on the same page. |
Since OSGeo/grass#7760 consolidated every manuals tree (stable, dev, numbered) onto the grass-stable canonical, the grass85, grass-devel, and grass86 child sitemaps now emit identical grass-stable URLs. Listing them in the sitemap index just feeds Google duplicate, non-canonical version URLs. Reference only sitemap_hugo.xml and grass-stable/manuals/sitemap.xml so the submitted index matches the canonical set. Dev docs are handled separately via noindex in core.
Fixes #5935
Problem
python/grass/docs/conf.pyassignedhtml_baseurltwice to conflicting values. Bothsphinx-sitemapand Sphinx's own canonical-link generation read that single variable, so the last assignment won for both:conf.pycanonical base (correct):.../grass-stable/manuals/libpython/https://grass.osgeo.org/, withsitemap_url_scheme = "grass{version}manuals/libpython/{link}"where{version}= the full dev string8.6.0dev.Live result: every libpython page emitted
<link rel="canonical" href="https://grass.osgeo.org/exceptions.html">(bare root), andgrass-devel/manuals/libpython/sitemap.xmllistedhttps://grass.osgeo.org/grass8.6.0dev/manuals/libpython/...(404). The merge step then re-stamped the merged manuals sitemap to the numericVERSION, breaking it too.Fix
Per the direction in the issue thread (URLs should be
grass86, i.e. the numberedgrass<MAJOR><MINOR>tree, which serves 200):conf.py: derive a shortgrass<MAJOR><MINOR>prefix fromcore.version()and use a singlehtml_baseurl = https://grass.osgeo.org/grass86/manuals/libpython/. Setsitemap_url_scheme = "{link}"so each sitemap<loc>equals the canonical URL exactly and resolves to the published numbered tree. No dependency on the full dev version string.utils/merge_sitemaps.py: make the version rewrite opt-in (--versiondefaults toNone); when omitted, each source sitemap keeps its own prefix. Adds a unit test forcheck_url_version.documentation.yml: drop the--version "${VERSION}"override so the mergedmanuals/sitemap.xmlkeepsgrass-stablecore-manual URLs andgrass86libpython URLs (each matching its own canonical).Scope is intentionally libpython (Sphinx) only; the MkDocs core manuals stay on their current
grass-stablecanonical.Verification
pytest utils/test_merge_sitemaps.py(5 passing): preserve when no version, rewrite when a version is given.--versionrewrite.8.6.0dev/8.6.0->grass86,8.10.0dev->grass810.documentation.ymlCI can build the docs and the generatedlibpython/sitemap.xml+ a page canonical can be checked end-to-end.Drafted with AI assistance.