Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ def smv_rewrite_configs(app, config):
# conf.py). Instead, hook into the 'config-inited' event which is late enough
# to rewrite the various configuration items with the current version.
if app.config.smv_current_version != '':
app.config.html_baseurl = app.config.html_baseurl + '/' + app.config.smv_current_version
app.config.html_baseurl = (
f"https://docs.ros.org/en/{app.config.smv_current_version}"
)
Comment on lines +308 to +310
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.

app.config.project = 'ROS 2 Documentation: ' + app.config.smv_current_version.title()

app.config.html_logo = 'source/Releases/' + app.config.smv_current_version + '-small.png'
Expand Down