Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Use sphinxext-opengraph to generate OpenGraph metadata#99931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
CAM-Gerlach left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Big picture comments (literally):
- The image is rather big, and takes up a large amount of space in the preview disproportionate (IMO) relative to its value for readers. Can we make it a lot smaller (especially in height), trim off the borders and/or otherwise ensure it is scaled down.
- Of the options listed, I prefer Python Docs, but I imagine the PSF trademarks committee might need to review it if its something other than one of the official logotypes.@malemburg ?
- We should backport it to at least the primary/default version site for this to have proper effect, but can we add the extension in a way that will gracefully fallback if the plugin is not installed (e.g. on downstream redistributors, who are unlikely to need, want or have it)?
ezio-melotti commentedDec 2, 2022
IIRC this is the standard/recommended size, but otherwise I agree that it could be smaller.
+1
We have already checked with them while working on the Devguide PR and mentioned that we are planning to do the same on related repos, so everything should be already ok on this front. |
hugovk commentedDec 2, 2022
Yes, the required minimum is 200 x 200 and recommended minimum is 1200 x 630, with 1.91:1 aspect ratio. https://developers.facebook.com/docs/sharing/webmasters/images says:
As a quick test, autocropping to 1022 x 330: https://hugovk-cpython.readthedocs.io/en/add-og-metadata2/whatsnew/3.12.html Gives: |
hugovk commentedDec 2, 2022
@AA-Turner Do you know if this is possible with Sphinx? |
hugovk commentedDec 2, 2022
CAM-Gerlach commentedDec 2, 2022
Okay; could you try to output it at 482 x 200 and see if it displays smaller? Or at the recommended minimum size?
try:importsphinxext.opengraphexceptImportError:passelse:extensions.append("sphinxext.opengraph")
I guess multiline, if its a mixed aspect ratio. If we must use the space, may as well get as much out of it as we can... |
CAM-Gerlach commentedDec 2, 2022
I added |
hugovk commentedDec 2, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Here's how 482 x 200 looks: (Note to self: This is smaller because Facebook says:
Therecommended minimum 1200 x 630 that we started with. The "absolute" minimum is 200 x 200, it's just the icon and looks like: (
Ah yes, thanks :)
👍 |
malemburg commentedDec 2, 2022
Please send in the final version for official approval. The versions I'm seeing on this ticket mostly appear fine. Just please make sure that the logo is not shown cut-off in parts. I know that this is difficult with social media links, but it would be good to at least have the complete logo shown in the previews. |
CAM-Gerlach commentedDec 2, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The smaller version takes up a lot less unnecessary space, though it does omit the "Python Docs" nameplate/logotype. Naively to me, the former would seem worth it, but I don't have the same background in the uses of opengraph metadata, beyond anecdotal experience with the displayed previews a handful of common places. What do others think? |
hugovk commentedDec 4, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Here's a whole load of demos with various sizes:
I think the square logo version without the "Python Docs" text is quite good, we're not showing a big banner photo and it shows more of the relevant text too. 400x400 seems to be the upper bound to still show as a square logo: Here's 200x200, looks about the same: In Discord: In Slack: So I think 200x200 is a good one to use. I'll update this PR and add a bit of padding too so it's not too close to the border for Facebook. |
hugovk commentedDec 4, 2022
Updated to 200x200 logo with 5px padding, demo athttps://hugovk-cpython.readthedocs.io/en/add-og-metadata2/whatsnew/3.12.html |
ezio-melotti commentedDec 4, 2022
One data point that might be relevant to the discussion is that (at least on Discord) clicking on the image just opens the image -- not the link. This behavior is useful when sharing cat pics from your favorite social media website, since you mostly care about the pic itself (and you would generally be better off avoiding the comment section). However in our case we don't care about the image itself, and having such a big image will just increases the chances that the user will click that instead of the actual link. IOW, the 200x200 logo might be a better fit for our use-case. |
CAM-Gerlach left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM, aside from adding relevant links to the NEWS entry. Thanks@hugovk !
Misc/NEWS.d/next/Documentation/2022-12-02-17-08-08.gh-issue-99931.wC46hE.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
CAM-Gerlach commentedDec 5, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hmm, interesting...I wasn't aware of this behavior, though this tends to imply that either it isn't widespread, or because I as a user have never actually tried to click the image. |
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Misc/NEWS.d/next/Documentation/2022-12-02-17-08-08.gh-issue-99931.wC46hE.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
miss-islington commentedDec 8, 2022
Thanks@hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
bedevere-bot commentedDec 8, 2022
GH-100115 is a backport of this pull request to the3.11 branch. |
(cherry picked from commitf49c735)Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
hugovk commentedDec 8, 2022
Backporting to 3.11, so we get it under the default |
(cherry picked from commitf49c735)Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>














Uh oh!
There was an error while loading.Please reload this page.
Forpython/docs-community#63.
Similar topython/devguide#953 already deployed for the devguide.
AddOpen Graph metadata usinghttps://github.com/wpilibsuite/sphinxext-opengraph.
This adds
<meta name="description">and<meta property="og:*">metadata, such as:Demo
With another branch, I temporarily changed this so the image link works:
https://hugovk-cpython.readthedocs.io/en/add-og-metadata2/whatsnew/3.12.html
SEO
Helps SEO by adding
<meta name="description">.SEO measurements using Google's PageSpeed Insights (using
mainon my RTD vs. mydemo on RTD to keep as many hosting variables the same):Notably fixes "Document does not have a meta description".
Sharing
This also improves the previews when sharing on Facebook, Slack, Discord, Twitter, etc.
For example, using the Facebook sharing deebugger:
Here's both shared on Slack:
OG image
Likepython/devguide#953, generated withhttps://github.com/hugovk/pixel-tools/blob/1618b2a09bd5998899958856b7fef4503f95cba2/og_image.py using the font fromhttps://github.com/python/pythondotorg/tree/main/static/fonts:
What text should we have in the image? The PR currently has "CPython", here's a few other options (all font size 210 except the last is 180). For multiple words, I could adjust
og_image.pyto do multiline text too.Note
The homepage and download pagesdo not get metadata, for example:
I think it's because because they're additional pages added via
conf.pylike this?If these also need it, should they be dealt with separately?
Skip issue or news?
We havepython/docs-community#63, should we also have an issue in this repo? And news?