sphinx_rtd_theme icon indicating copy to clipboard operation
sphinx_rtd_theme copied to clipboard

Workaround for dirhtml builder with wrong canonical URLs

Open benjaoming opened this issue 2 years ago • 5 comments

Fix for #1406

  • [x] Fix index.html being converted to index/

(will test manually since canonical URL does not seem to appear in local builds)

benjaoming avatar Jan 11 '23 14:01 benjaoming

@ericholscher yes, agreed -- I would think that setting html_baseurl in conf.py is enough to mimic the intended behavior. LMK if you had other thoughts.

I don't think this needs to be a roadmap item for 1.2.0 but would be nice to publish it sooner or later.

benjaoming avatar Jan 11 '23 19:01 benjaoming

I'm going to leave this for a little while - but I don't think it's hard to add a test dimension in Tox that parameterizes conf.py in a similar fashion to how we are doing with -D writer=html4writer. It could be something like -D 'writer=dirhtml' -D 'html_baseurl=https://example.com' and then a verification that the canonical URL is set correctly in the output HTML.

benjaoming avatar Jan 12 '23 09:01 benjaoming

I am noticing that sphinx itself would have the same issue here: https://github.com/sphinx-doc/sphinx/blob/master/sphinx/themes/basic/layout.html#L132

Probably best to use a mixture of https://www.sphinx-doc.org/en/master/development/templating.html#file_suffix and https://www.sphinx-doc.org/en/master/development/templating.html#pagename

Blendify avatar Jan 17 '23 03:01 Blendify

@Blendify this is just a workaround :) You'll find the upstream issue here: https://github.com/sphinx-doc/sphinx/issues/9730

benjaoming avatar Jan 17 '23 11:01 benjaoming

Thanks for this, @benjaoming, @humitos. This would indeed help with https://github.com/readthedocs/sphinx_rtd_theme/issues/1303 for now!

dmalan avatar Apr 15 '23 04:04 dmalan