-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use sphinxext-opengraph to generate OpenGraph metadata #99931
Conversation
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)?
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. |
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: |
@AA-Turner Do you know if this is possible with Sphinx? |
Okay; could you try to output it at 482 x 200 and see if it displays smaller? Or at the recommended minimum size?
try:
import sphinxext.opengraph
except ImportError:
pass
else:
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... |
I added |
Here's how 482 x 200 looks: (Note to self: This is smaller because Facebook says:
The recommended 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 :)
👍 |
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. |
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? |
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. |
Updated to 200x200 logo with 5px padding, demo at https://hugovk-cpython.readthedocs.io/en/add-og-metadata2/whatsnew/3.12.html |
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. |
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
Outdated
Show resolved
Hide resolved
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 <[email protected]>
Misc/NEWS.d/next/Documentation/2022-12-02-17-08-08.gh-issue-99931.wC46hE.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: C.A.M. Gerlach <[email protected]>
Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
GH-100115 is a backport of this pull request to the 3.11 branch. |
(cherry picked from commit f49c735) Co-authored-by: Hugo van Kemenade <[email protected]> Co-authored-by: C.A.M. Gerlach <[email protected]>
Backporting to 3.11, so we get it under the default |
(cherry picked from commit f49c735) Co-authored-by: Hugo van Kemenade <[email protected]> Co-authored-by: C.A.M. Gerlach <[email protected]>
For python/docs-community#63.
Similar to python/devguide#953 already deployed for the devguide.
Add Open Graph metadata using https://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
main
on my RTD vs. my demo 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
Like python/devguide#953, generated with https://github.com/hugovk/pixel-tools/blob/1618b2a09bd5998899958856b7fef4503f95cba2/og_image.py using the font from https://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.py
to do multiline text too.Note
The homepage and download pages do not get metadata, for example:
I think it's because because they're additional pages added via
conf.py
like this?If these also need it, should they be dealt with separately?
Skip issue or news?
We have python/docs-community#63, should we also have an issue in this repo? And news?