mirror of
https://github.com/astral-sh/ruff.git
synced 2026-12-04 02:03:58 +08:00
## 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/) <img width="661" height="413" alt="Screenshot 2026-01-25 at 2 31 37 AM" src="https://github.com/user-attachments/assets/d5e1ee46-346e-4e88-9d41-af238d9f0ca0" /> <img width="661" height="330" alt="Screenshot 2026-01-25 at 2 31 45 AM" src="https://github.com/user-attachments/assets/39249e06-708e-4486-a488-437ed83656bf" /> <img width="661" height="438" alt="Screenshot 2026-01-25 at 2 31 54 AM" src="https://github.com/user-attachments/assets/305a7a69-b5d0-4fa2-bfa0-7a40eb71a98b" /> ### How it looks if a specific page is shown The card should also display the correct title, depending on the page that was shared. <img width="661" height="438" alt="Screenshot 2026-01-25 at 2 53 26 AM" src="https://github.com/user-attachments/assets/9be20f40-afe6-4b21-b6e7-f8c25dd8a67c" /> ## Test Plan <!-- How was it tested? --> 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: <img width="661" height="438" alt="Screenshot 2026-01-25 at 4 06 48 AM" src="https://github.com/user-attachments/assets/02b1ac8f-2080-452f-861e-400a26ce172a" /> <img width="661" height="438" alt="Screenshot 2026-01-25 at 4 06 55 AM" src="https://github.com/user-attachments/assets/23608ae5-88fb-495d-b4e8-1d658dacd8fe" /> <img width="661" height="438" alt="Screenshot 2026-01-25 at 4 06 58 AM" src="https://github.com/user-attachments/assets/190e9564-03d1-4133-924a-e6870499e446" /> 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? --------- Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>