Skip to content

Bug: Sitemap generates duplicate language paths (/en/stable/en/) regardless of html_baseurl configuration #13185

Description

@BillSousa

Details

Project: https://pybear.readthedocs.io/

Environment:
Sphinx Version: 9.1.0
Sphinx Theme: pydata_sphinx_theme
Python Version: 3.12

Problem:
All sitemap URLs contain a doubled /en/ path, making them invalid 404s:
https://pybear.readthedocs.io/en/stable/en/index.html ← broken
https://pybear.readthedocs.io/en/stable/index.html ← correct
Root cause identified:
RTD injects -D language=en into the Sphinx build command:
python -m sphinx -T -b html -d _build/doctrees -D language=en . $READTHEDOCS_OUTPUT/html
This causes Sphinx 9.x to output files into an en/ subdirectory, making page links resolve to en/somepage.html. Combined with html_baseurl, this produces doubled paths in the sitemap.
Confirmed:

RTD's native sitemap has the same bug regardless of sphinx-sitemap being present or absent
Setting html_baseurl to either https://pybear.readthedocs.io/ or https://pybear.readthedocs.io/en/stable/ does not fix it
Actual pages load correctly at the right URLs
Canonical tags on pages are correct

Impact:
Google Search Console flags these pages as "Duplicate, Google chose different canonical than user" and drops them from the index because the sitemap directs crawlers to broken paths while canonical tags point to the correct URLs. This causes steady decline in indexed pages over time.
Requested Fix:
Update the sitemap generation to normalize URLs so that platform-level language/version strings are not duplicated regardless of html_baseurl or Sphinx environment variables.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SupportSupport question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions