wpilibsuite / sphinxext-opengraph

Sphinx extension to generate unique OpenGraph metadata
https://sphinxext-opengraph.readthedocs.io
Other
74 stars 27 forks source link

Do not append `index` with `dirhtml` #77

Closed hugovk closed 1 year ago

hugovk commented 1 year ago

Steps to reproduce

  1. Build docs using dirhtml that has ogp_site_url = "https://devguide.python.org/" in conf.py

    git clone https://github.com/python/devguide
    cd devguide
    make dirhtml
    # or:
    # sphinx-build -b dirhtml -d _build/doctrees  -W --keep-going -n . _build/dirhtml
  2. Open a non-index page, for example _build/dirhtml/getting-started/getting-help/index.html and check og:url:

<meta property="og:url" content="https://devguide.python.org/getting-started/getting-help/" />

  1. Open a index page, _build/dirhtml/index.html and check og:url

Actual result

❌ Appends index to give a 404 URL: https://devguide.python.org/index/

<meta property="og:url" content="https://devguide.python.org/index/" />

Expected result

Don't append index for the main page:

<meta property="og:url" content="https://devguide.python.org/index/" />

See also

This came up at https://github.com/python/devguide/pull/953#issuecomment-1274377631, see the demo build at https://cpython-devguide--953.org.readthedocs.build/

hugovk commented 1 year ago

Also need to deal with other index pages, such as _build/dirhtml/getting-started/index.html:

<meta property="og:url" content="https://devguide.python.org/getting-started/index/" />

https://devguide.python.org/getting-started/index/

https://devguide.python.org/getting-started/

hugovk commented 1 year ago

PR https://github.com/wpilibsuite/sphinxext-opengraph/pull/78 updated.