Repository navigation
Add OG image and social preview meta tags - #2233
astra-intelligence wants to merge 4 commits into
Conversation
git-scm.com had no og:/twitter: meta tags, so every shared link (homepage, docs, cheat-sheet, book) rendered a blank preview card. - Add og:image/og:title/og:url/og:description + twitter:card meta tags to the default head, with a site-wide 1200x630 card at /images/og-image.png matching the site's palette (#f14e32 orange). - Add Pillow-only tools/make-og-image.py so the card is reproducible. Co-Authored-By: Paperclip <noreply@paperclip.ing>
dscho
left a comment
There was a problem hiding this comment.
The PR description looks plausible, but a lot of AI hallucinations do. As a rule, I therefore much prefer claims to be backed up by references to authoritative sources. A link to a W3C guidance or equally trustworthy, human-authored content, for those og:* tags would therefore go quite a long way.
With that out of the way, I have issues with the actual execution. The changes to baseof.html look good (even if they add quite a bit of boiler-plate to every single content page!), but the image (and its generation script) cannot stand as-is.
There was a problem hiding this comment.
Hmm. This screenshot feels like it was taken last millenium... Maybe we could have a more current one?
There was a problem hiding this comment.
The new image looks better, but it 1) is cut off at the bottom, and 2) contains the hard-coded version v2.56.0 (which won't age well)...
| @@ -0,0 +1,88 @@ | |||
| #!/usr/bin/env python3 | |||
There was a problem hiding this comment.
We already have Ruby and Node.JS scripts in this repository (the former for historical reasons; the site used to be a Rails app, the latter to integrate better with GitHub workflows and with modern, Playwright-based testing).
Some people might say "the more the merrier" but I would disagree: Every additional language used in a project at least doubles the bar for any new contributor. Therefore I am opposed to this.
Besides, why create a totally new image? One that looks nothing like the site? Should the og:image not reflect the site's look and feel? We already have prior art in this repository to take snapshots of the site: https://github.com/git/git-scm.com/blob/gh-pages/script/compare-screenshots.js.
Speaking of which, it should be obvious to even a casual observer that scripts in this project live in scripts/. Inventing a new convention and placing the new script into tools/ is therefore willfully being inconsistent, which I am also opposed to.
This comment was marked as spam.
This comment was marked as spam.
… (script/take-og-image.js), drop Python generator Per maintainer review on git-scm.com#2233: - Replace the hand-drawn Pillow card with a genuine 1200x630 screenshot of the homepage (light mode), taken with the repo's existing Playwright tooling (mirrors script/compare-screenshots.js): hugo build -> serve-public.js -> chromium clip at 1200x630. - Remove tools/make-og-image.py (Python) so the repo gains no new scripting language; the generator lives in script/ per repo convention. - Add authoritative references (ogp.me Open Graph protocol, X Cards docs) in the PR description.
|
Thanks for the detailed review, @dscho — all three points addressed:
Regenerate anytime with: node script/take-og-image.jsThe |
… (stderr is inherited, not piped) The spawn uses stdio ['ignore','pipe','inherit'] so server.stderr is null; attaching a data listener on it threw TypeError and aborted startup before the screenshot. Mirror compare-screenshots.js exactly: wait on stdout only. Regenerated og-image.png via the script (canonical output).
…om cutoff Hide the ever-changing 'Latest source release' box (which hard-coded the version number) and the lower-page content so the 1200x630 card shows the header, hero, and first two feature-grid rows on a clean boundary — no stale version, nothing cut off at the bottom.
|
Thanks @dscho — both points addressed in 2a9b903:
The generator ( |
What
git-scm.com currently ships zero
og:*/twitter:*meta tags — every link shared on Slack, Discord, X, or LinkedIn renders a blank preview card, including the homepage, docs, cheat-sheet, and the Pro Git book pages.This adds site-wide social preview tags to the default head:
og:site_name,og:title,og:type,og:url,og:descriptionog:image+og:image:type/width/height→ a 1200×630 card at/images/og-image.pngtwitter:card=summary_large_image,twitter:title,twitter:description,twitter:imageThe card matches the site's existing palette (
#f14e32Git orange used by--orangeinassets/sass/dark-mode.scss,#fcfcfamain background,#4e443ctext) and uses the site's own tagline wording.Files
layouts/_default/baseof.html— meta tags in the default head (after<title>)static/images/og-image.png— the 1200×630 cardtools/make-og-image.py— Pillow-only generator (no new runtime deps; card is reproducible)Verification
Built locally with the repo's pinned Hugo (
0.161.1-era config,hugo.yml): the tags render onindex.htmland every page layout. The CI "no absolute URLs" check only scanshref/srcattributes; these arecontentattributes on canonicalhttps://git-scm.com/...URLs, so they pass untouched.Preview of the card: https://github.com/astra-intelligence/git-scm.com/blob/add-og-social-preview/static/images/og-image.png