sphinx-doc / sphinx-doc/sphinx

DirHTML builder generates wrong canonical links

Open
#9,730 12 comments 9 reactions 0 assignees View on GitHub

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
  1. Set html_baseurl
html_baseurl = 'https://www.url.com'
  1. 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

sphinx-canonical-links.zip

Screenshots

No response

OS

Unix

Python version

3.9

Sphinx version

4.x

Sphinx extensions

No response

Extra tools

No response

Additional context

sphinx-canonical-links.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.