| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
|
||
| # sphinxext-opengraph config | ||
| ogp_site_url = "https://devguide.python.org/" | ||
| ogp_image = "https://devguide.python.org/_static/python-logo.svg" |
There was a problem hiding this comment.
Apparently SVGs are not supported, so we should use a different image.
Should we also add more variables?
Sorry, something went wrong.
There was a problem hiding this comment.
Will find another image. The recommended image size is 1200 x 630, should we use a Python logo or something else?
I don't think we need any of the other variables.
Sorry, something went wrong.
There was a problem hiding this comment.
Re: other variables:
I'll check ogp_custom_meta_tags for <meta name="description">.
Sorry, something went wrong.
There was a problem hiding this comment.
I'll check ogp_custom_meta_tags for <meta name="description">.
We can use ogp_custom_meta_tags to add it, but it would be hardcoded and we'd like to generate it from each page.
Sorry, something went wrong.
There was a problem hiding this comment.
The recommended image size is 1200 x 630, should we use a Python logo or something else?
Since the image is rectangular (and somewhat big), it would be nice if it had both the Python logo and the text "Devguide". If/when we do the same for cpython (or for the peps repo), we can have the same logo but different texts, so that the links are easily distinguishable.
This however would require creating new images, so if you don't want to do that, just a simple logo will do (we can always update the image later).
I don't think we need any of the other variables.
ok
We can use ogp_custom_meta_tags to add it, but it would be hardcoded and we'd like to generate it from each page.
Right, it would be better if the description was created dynamically.
Sorry, something went wrong.
There was a problem hiding this comment.
SVG replaced with a PNG of the Python logo + "Devguide".
I wrote a script to create it (hugovk/pixel-tools#15), so we can re-use that for other repos if we want.
I also squashed out the extra bytes from the PNG using optipng -o7 -zm1-9 _static/og-image.png (57,118 -> 9,573 bytes, 16.76% decrease).
When temporarily setting ogp_image = "https://cpython-devguide--953.org.readthedocs.build/_static/og-image.png" Facebook's sharing debugger shows the following OG metadata/preview:
Also included og:image:width and og:image:height because the debugger said "Using these tags will specify the image to the crawler so that it can render it immediately without having to asynchronously".
Sorry, something went wrong.
There was a problem hiding this comment.
The new image looks good -- I wonder if we can use the same font used with the logo though.
https://www.python.org/community/logos/ says
The font used in the logo is called "Flux Regular". The PSF owns a copy but we cannot distribute it, except for work on the PSF's behalf.
Further down on the same page it says:
In general, we want the logo to be used as widely as possible to indicate use of Python or suitability for Python. However, please ask first when using a derived version of the logo or when in doubt.
So we should ask there first, and if they agree we can regenerate the logos with the right font.
This is not a blocker by any means though, so we can merge with the current image and recreate it later.
Sorry, something went wrong.
There was a problem hiding this comment.
It's taking a while to get the font. It would be nice to get this merged to see how it works when live. Shall we merge this as-is, or with the image removed?
Sorry, something went wrong.
There was a problem hiding this comment.
Let's merge it.
I'll ping Deb again about the font and we can update that in a follow-up PR.
Sorry, something went wrong.
There was a problem hiding this comment.
(Continued in main thread: #953 (comment))
Sorry, something went wrong.
Sorry, something went wrong.
|
|
||
| # sphinxext-opengraph config | ||
| ogp_site_url = "https://devguide.python.org/" | ||
| ogp_image = "https://devguide.python.org/_static/python-logo.svg" |
There was a problem hiding this comment.
The new image looks good -- I wonder if we can use the same font used with the logo though.
https://www.python.org/community/logos/ says
The font used in the logo is called "Flux Regular". The PSF owns a copy but we cannot distribute it, except for work on the PSF's behalf.
Further down on the same page it says:
In general, we want the logo to be used as widely as possible to indicate use of Python or suitability for Python. However, please ask first when using a derived version of the logo or when in doubt.
So we should ask there first, and if they agree we can regenerate the logos with the right font.
This is not a blocker by any means though, so we can merge with the current image and recreate it later.
Sorry, something went wrong.
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
There was a problem hiding this comment.
I tested the latest iteration and got this:

The website name works, but the image still doesn't (it loads for a while and then 💩).
This is because it currently points to https://devguide.python.org/_static/og-image.png, so the suggestion below should fix it.
Sorry, something went wrong.
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
|
I saw that in the source of https://cpython-devguide--953.org.readthedocs.build/ there is a <meta property="og:url" content="https://devguide.python.org/index/" />, and https://devguide.python.org/index/ is a 404. With the dirhtml builder sphinxext-opengraph is adding the name of the current page to the url: On the main page (i.e. /) this ends up appending an extra index/ resulting in the 404. |
Sorry, something went wrong.
|
This would be better fixed upstream, as it will break for other sites using dirhtml. Please could you report? |
Sorry, something went wrong.
|
Reported at sphinx-doc/sphinxext-opengraph#77 and created PR sphinx-doc/sphinxext-opengraph#78. |
Sorry, something went wrong.
The dirhtml bug is fixed and released in sphinxext-opengraph 0.7.1! 🚀 Also, to help python/docs-community#65, my PR sphinx-doc/sphinxext-opengraph#71 to use og:description as description is also part of 0.7.1 and enabled by default. Here's a demo branch and build with the URL fixed so the image URL works (hugovk@483ee38) Here's a page in the Facebook sharing debugger: Here's a Slack share (demo and current site): And Discord: |
Sorry, something went wrong.
|
Noticed you have a Discord example. Adding a "theme-color" meta tag lets you customize the color of the vertical bar on the left side of the Discord embed. |
Sorry, something went wrong.
Sorry, something went wrong.
|
I found the fonts in https://github.com/python/pythondotorg/tree/main/static/fonts so have regenerated the image using https://github.com/hugovk/pixel-tools/blob/1618b2a09bd5998899958856b7fef4503f95cba2/og_image.py like: python og_image.py --logo tests/python-logo.png --size 210 --font ../pythondotorg/static/fonts/FluxRegular.ttf
...
optipng -o7 -zm1-9 _static/og-image.png # 16.28% decreaseDemohttps://hugovk-devguide.readthedocs.io/en/add-og-metadata2/testing/run-write-tests/ Preview in FacebookPreview in Slack |
Sorry, something went wrong.
| ogp_custom_meta_tags = [ | ||
| '<meta property="og:image:width" content="1200">', | ||
| '<meta property="og:image:height" content="630">', | ||
| '<meta name="theme-color" content="#3776ab" />', |
There was a problem hiding this comment.
FWIW I looked into using a gradient that matches both colors of the Python logo, but this doesn't seem supported.
Sorry, something went wrong.
Google's SEO checksUsing their PageSpeed Insights tool: https://pagespeed.web.dev/report?url=https%3A%2F%2Fdevguide.python.org%2F&form_factor=desktop
|
Sorry, something went wrong.
Facebook sharing previewhttps://developers.facebook.com/tools/debug/?q=https%3A%2F%2Fdevguide.python.org%2F
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Add Open Graph metadata using https://github.com/wpilibsuite/sphinxext-opengraph.