sphinx-doc / sphinx-doc/sphinx
DirHTML builder generates wrong canonical links
Open
Nobody has claimed this yet.
builder:dirhtml
type:bug
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Using the dirhtml builder results in pages with canonical links of the form
<link rel="canonical" href="https://www.url.com/search.html" />
for the index document _website/search/index.html
How to Reproduce
- Set html_baseurl
html_baseurl = 'https://www.url.com'
- Build documentation using dirhtml builder
sphinx-build -b dirhtml . _website/
Expected behavior
The canonical link has either the form
<link rel="canonical" href="https://www.url.com/search/" />
or
<link rel="canonical" href="https://www.url.com/search/index.html" />
Your project
Screenshots
No response
OS
Unix
Python version
3.9
Sphinx version
4.x
Sphinx extensions
No response
Extra tools
No response
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with html_baseurl set to https://www.url.com and the dirhtml command shown in the report, then trace how the canonical link is generated for _website/search/index.html. Done means the generated canonical URL uses either /search/ or /search/index.html rather than /search.html.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100