Skip to content

Serve a PNG Open Graph image so link previews render#106

Merged
desko27 merged 1 commit into
mainfrom
claude/reddit-og-image-preview-gk2sy
Jun 2, 2026
Merged

Serve a PNG Open Graph image so link previews render#106
desko27 merged 1 commit into
mainfrom
claude/reddit-og-image-preview-gk2sy

Conversation

@desko27

@desko27 desko27 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Problem

Sharing the site on Reddit (and elsewhere) showed no preview — just a generic globe placeholder. The cause: og:image pointed at og.svg, and no major platform renders an SVG Open Graph image. Reddit, X/Twitter, Facebook, LinkedIn, Slack, Discord and iMessage all ignore an SVG og:image and fall back to a placeholder, so shared links looked broken.

Fix

  • Rasterize og.svg into a 1200×630 og.png and point the meta tags at it.
  • Add og:image:type, og:image:width, og:image:height, og:image:alt and twitter:image:alt for a more reliable, richer preview.
  • Keep og.svg as the editable source of truth; a small script (sites/web/scripts/generate-og.mjs) renders the PNG with vendored Geist + Fira Code TTFs, loaded explicitly so the output is deterministic and on-brand regardless of the build machine's installed fonts (resvg renders no text at all when it can't resolve a font).

Regenerate after editing og.svg:

pnpm --filter web og

Verification

  • astro build passes and og.png is emitted to dist.
  • Built HTML references the absolute PNG URL in the OG/Twitter meta tags.
  • Pre-commit hook green (Biome lint + tsc -b).

Note: platforms cache previews per URL. The old Reddit link won't update until its cache is refreshed (e.g. via the Facebook Sharing Debugger or a ?v= querystring), but new links will pick up the PNG immediately.

The site's og:image pointed at og.svg, but no major platform renders an
SVG Open Graph image — Reddit, X, Facebook, LinkedIn, Slack, Discord and
iMessage all ignore it and fall back to a generic placeholder, which is
why the recent Reddit post showed a blank globe instead of a preview.

Rasterize og.svg into a 1200x630 og.png and point the meta tags at it,
adding og:image:type/width/height/alt and twitter:image:alt. og.svg
stays the editable source of truth; a small script renders the PNG with
vendored Geist + Fira Code TTFs (loaded explicitly so the output is
deterministic and on-brand regardless of the build machine's fonts).

Run `pnpm --filter web og` after editing og.svg to regenerate.
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-call Ready Ready Preview, Comment Jun 2, 2026 9:29pm

@desko27 desko27 merged commit 001f946 into main Jun 2, 2026
8 checks passed
@desko27 desko27 deleted the claude/reddit-og-image-preview-gk2sy branch June 2, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant