Fix sitemap URLs: every entry currently 404s - #14
Open
bloxster wants to merge 1 commit into
Open
Conversation
html_baseurl ends in /en/latest/, and sphinx-sitemap 2.2.0 defaults
sitemap_url_scheme to "{lang}{version}{link}", so the language segment is
emitted twice and the sitemap advertises /en/latest/en/<page>.html. Setting the
scheme to "{link}" stops that.
html_baseurl now also prefers READTHEDOCS_CANONICAL_URL, so a build of
/en/master/ no longer advertises /en/latest/ URLs. Uses the os import already
present in the file.
Verified against sphinx-sitemap 2.2.0, the pinned version, with a minimal
build in both modes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every URL in the published sitemap returns 404.
html_baseurlends in/en/latest/, andsphinx-sitemap2.2.0 defaultssitemap_url_schemeto{lang}{version}{link}, so the language segment is emitted a second time:Setting
sitemap_url_scheme = "{link}"stops the duplication, since the base URL already carries both segments. ({version}expands to nothing here, asversionis empty — only the language is duplicated.)Second, smaller fix.
html_baseurlwas hardcoded to/en/latest/, so a build of any other version advertisedlatestURLs regardless. Read the Docs serves this project at/en/master/as well. It now prefersREADTHEDOCS_CANONICAL_URL, which Read the Docs sets to the canonical URL of the version under build, and falls back to the previous literal for local builds. This uses theosimport already present at the top of the file.Verification. Built a minimal project against
sphinx-sitemap==2.2.0(the pinned version) with this exact configuration:<loc>…/en/latest/en/index.html— 404 live…/en/latest/index.html— 200 liveREADTHEDOCS_CANONICAL_URL=…/en/master/…/en/master/index.html— 200 liveWorth noting the two versions currently publish the same content under different version stamps in search results, which this does not address — but a sitemap that resolves is a precondition for search engines sorting that out.