Skip to content

Conversation

@attu0
Copy link

@attu0 attu0 commented Jan 13, 2026

Description

This PR fixes canonical URL generation for sphinx-multiversion builds by
explicitly setting html_baseurl to include the ROS distribution
(e.g. https://docs.ros.org/en/rolling).

This prevents mirrors or alternate build environments from generating
incorrect canonical URLs that omit the ROS distribution or use
non-official domains.

Fixes #6112.

Did you use Generative AI?

Yes — ChatGPT (for guidance and explanation only).

Additional Information

  • Implemented as a clean commit on top of rolling
  • No unrelated documentation history included

@attu0
Copy link
Author

attu0 commented Jan 13, 2026

@fujitatomoya Thanks for the guidance!

I’ve recreated the change as a clean commit on top of rolling and opened
a new PR targeting the rolling branch, as requested.

Comment on lines +308 to +310
app.config.html_baseurl = (
f"https://docs.ros.org/en/{app.config.smv_current_version}"
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not think replacing this with hardcodes will fix the issue described in #6112, can you explain this why this is the fix from your understanding? (or are you just posting the suggested fix by ChatGPT?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review

From my understanding of #6112, the issue occurs specifically in
sphinx-multiversion builds where html_baseurl is set to
https://docs.ros.org/en, while the generated pages live under
/en/<distro>/…. In that case, Sphinx generates canonical links that
omit the distro segment, which is what causes incorrect canonicals on
mirrors.

In this repository, canonical URLs are generated by the Sphinx HTML
builder using html_baseurl + the page-relative path. By rewriting
html_baseurl only when smv_current_version is set, the builder
produces canonical URLs of the form >> https://docs.ros.org/en//.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this only fixes canonicals generated by the HTML builder. If you’d prefer this handled at a different layer (such as template-level canonical generation), I’m happy to change the implementation.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Canonical URL generation logic can lead to incorrect mirror results

2 participants