Skip to content

Add OG unfurl image to docs#22839

Open
cwkang1998 wants to merge 1 commit intoastral-sh:mainfrom
cwkang1998:feat/add-og-tags
Open

Add OG unfurl image to docs#22839
cwkang1998 wants to merge 1 commit intoastral-sh:mainfrom
cwkang1998:feat/add-og-tags

Conversation

@cwkang1998
Copy link
Contributor

Summary

Closes #8542.

This PR aims to make ruff's documentation sharing appear as a card on social medias via adding OpenGraph(OG) tags in the <head> section of the documentation.

Implementation

The og tags were added to docs/.override/main.html, and the image added is taken from playground/ruff/public/Ruff.png. The image was chosen since it fits the card better compared to using just the logo.

How it looks with the changes implemented (images from https://www.opengraph.xyz/)

Screenshot 2026-01-25 at 2 31 37 AM Screenshot 2026-01-25 at 2 31 45 AM Screenshot 2026-01-25 at 2 31 54 AM

How it looks if a specific page is shown

The card should also display the correct title, depending on the page that was shared.

Screenshot 2026-01-25 at 2 53 26 AM

Test Plan

The testing are mainly done on site such as https://www.opengraph.xyz/, with ngrok as a proxy to expose the local changes

Alternative implementation

There's a mkdocs-material social plugin that supports generating beautiful cards for each pages, which results in something like so:

Screenshot 2026-01-25 at 4 06 48 AM Screenshot 2026-01-25 at 4 06 55 AM Screenshot 2026-01-25 at 4 06 58 AM

More details for the plugin can be seen here: https://squidfunk.github.io/mkdocs-material/setup/setting-up-social-cards.

The plugin relies on extra dependencies for generating image: CairoSVG and pillow, and will require installation of native dependencies (details: https://squidfunk.github.io/mkdocs-material/plugins/requirements/image-processing/). When setting this up I do have some issues with uvx not detecting DYLD_FALLBACK_LIBRARY_PATH, but running it in the venv without uvx resolves this.

I went with the current approach instead of this alternative ones since I'm already done with the current approach by the time I found the social plugin.

Personally I do think the social plugin looks better in general, but would like some opinion on this matter: which will be the preferred implementation for ruff here?

@amyreese amyreese added documentation Improvements or additions to documentation labels Feb 5, 2026
@amyreese
Copy link
Member

amyreese commented Feb 5, 2026

Comparing the two cards shown, I prefer the one generated by the mkdocs plugin for a few reasons:

  • it includes "Ruff", since many users may not recognize the R logo on its own
  • it includes the page/section title, which is useful for viewer
  • it better matches the color scheme of the docs site

That said, I like that the PR uses a pre-generated image. How difficult would it be for a simple script to generate card images for each of the pages, more closely matching what the mkdocs plugin generates, but still check-in those images once rather than needing to have cairo installed to generate them every time the docs are built?

@ntBre
Copy link
Contributor

ntBre commented Feb 5, 2026

I don't really mind sticking with the same image used in the playground, especially in a first draft. When I looked at this previously, I was more concerned about a few missing og attributes relative to the playground:

<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@astral_sh" />
<meta property="og:title" content="Playground | Ruff" />
<meta
property="og:description"
content="An in-browser playground for Ruff, an extremely fast Python linter written in Rust."
/>
<meta property="og:url" content="https://play.ruff.rs" />
<meta property="og:image" content="/Ruff.png" />

Compared to the playground header, we have an extra og:type attribute and are missing the og:description and og:url tags. I'm not really familiar with OpenGraph at all, so I'm just trying to compare the two.

I definitely prefer not adding another mkdocs plugin, especially in case we end up moving away from mkdocs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add OG unfurl image to docs

3 participants