Skip to content

Conversation

nineteendo
Copy link

@nineteendo nineteendo commented Apr 22, 2025

The current logic of grabbing the root from the canonical url is wrong:

Screenshot 2025-04-22 at 11 22 10

You can easily see this if you remove this line from conf.py:

ogp_site_url = 'https://sphinxext-opengraph.readthedocs.io/en/latest/'

Then you get something like this:

<meta property="og:url" content="https://sphinxext-opengraph.readthedocs.io/index.html">
<meta property="og:image" content="https://sphinxext-opengraph.readthedocs.io/_images/social_previews/summary_index_c6c9679d.png">

Documentation preview: https://sphinxext-opengraph--135.org.readthedocs.build/en/135

@nineteendo nineteendo closed this Apr 22, 2025
@m-aciek
Copy link
Contributor

m-aciek commented May 16, 2025

Why did you close @nineteendo? Wasn't it a right approach?

@nineteendo
Copy link
Author

Because the code is correct:

>>> from urllib.parse import urljoin, urlparse, urlsplit, urlunsplit
>>> rtd_canonical_url = 'https://sphinxext-opengraph.readthedocs.io/en/latest/'
>>> parse_result = urlsplit(rtd_canonical_url)
>>> urlunsplit((parse_result.scheme, parse_result.netloc, parse_result.path, '', ''))
'https://sphinxext-opengraph.readthedocs.io/en/latest/'

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants