pydata / pydata-sphinx-theme

A clean, three-column Sphinx theme with Bootstrap for the PyData community
https://pydata-sphinx-theme.readthedocs.io
BSD 3-Clause "New" or "Revised" License
565 stars 304 forks source link

Canonical URLs wrong in dirhtml build #1675

Closed kathatherine closed 5 months ago

kathatherine commented 6 months ago

Hi all, I've just been made aware that the canonical URLs in one of my docsites are not matching the page URLs, which is causing issues with our SEO. Basically, the fact that these docs are created using the dirhtml build option means that the page URLs are ending in /, but the canonicals in the source HTML are showing as ending in index.html or .html, so that's the page type that Google is displaying in search, instead of the URL we want.

image

It's an upstream issue with Sphinx (https://github.com/sphinx-doc/sphinx/issues/9730) that has been open for over two years now.

Some themes are choosing to fix the issue themselves (Furo - https://github.com/pradyunsg/furo/issues/682, Sphinx awesome theme - https://github.com/kai687/sphinxawesome-theme/pull/1262) and I was wondering if pydata-sphinx-theme might choose to do the same. Unfortunately, I can't find any workarounds documented that aren't at the theme level and this is outside my area of expertise as a technical writer, so I thought I would ask here. Thank you!

drammock commented 6 months ago

The fix in https://github.com/pradyunsg/furo/pull/727/files looks simple enough. Whoever gets around to copy-pasting it here: we should probably list @davidism as co-author on the commit.

davidism commented 6 months ago

I've been exploring both Furo and Pydata as new base themes for Pallets projects, so I definitely wouldn't mind seeing my fix make it into here as well. A co-authored-by credit is a nice thought, thank you.