Skip to content

Add custom og:images#4860

Open
Duncanma wants to merge 3 commits into
mainfrom
AddCustomOpenGraphImages
Open

Add custom og:images#4860
Duncanma wants to merge 3 commits into
mainfrom
AddCustomOpenGraphImages

Conversation

@Duncanma

@Duncanma Duncanma commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Automatically generate social share (og:image) cards for every doc page

Problem

Every page on docs.temporal.io currently shares a single static og:image (themeConfig.image in docusaurus.config.js) — so a link to any page, whether the homepage or a deep SDK reference page, unfurls in Slack/X/LinkedIn with the exact same generic card. There's no way to give a page a more relevant preview without hand-making an image.

That image, below, is also huge (5.6MB)
Image

What this does

Adds a build-time Docusaurus plugin (plugins/og-image/) that generates a unique, on-brand social share card for every doc page automatically — no authoring work required. Each page will get an image like this

Image

These images will show up on Slack, Bluesky, X, etc.

**Before in slack (note the 6MB in the preview, that's Slack pointing out how large the preview image is)

Screenshot 2026-07-10 at 1 34 11 PM

After

Screenshot 2026-07-10 at 1 34 05 PM

How a card is built

Each card is 1200×630 and includes:

  • A section badge derived from the page's location (e.g. develop/go/...Go SDK, cloud/...Cloud)
  • The page title (front matter title, falling back to the first # heading, falling back to a humanized filename)
  • The page description, if present, clamped to 3 lines based on actual rendered width (not a fixed character count, so it always fills the available space without ever overflowing)
  • The Temporal logo and docs.temporal.io

Rendered with Satori + @resvg/resvg-js, then re-encoded through sharp as a palette-quantized PNG — cuts output size by ~88% (232.7KB → 28.9KB per card) with no visible quality loss, since the raw resvg PNG output has no compression options and the gradient background otherwise compresses poorly.

Manual overrides

Any page can opt out of the generated card:

  • Front matter image: field (existing Docusaurus mechanism), or
  • An inline <Head> component with its own og:image/twitter:image meta tags, for cases that need more control

The plugin detects either and leaves the page untouched. See the new "Social share images (og:image)" section in CONTRIBUTING.md for authoring instructions.

Caching

Generated images are cached by content hash (node_modules/.cache/og-images/) — nested under node_modules so it's gitignored for free and rides along with whatever already caches node_modules in CI/Vercel between builds. A page's card only regenerates when its title, description, section, or the template itself changes.

Performance

Measured across all ~625 doc pages:

  • Warm build (typical — cache hit): +0s, cards are just copied
  • Cold build (first build, or after a yarn.lock change): ~86s to render every card fresh (~106ms/card)
  • Output size: 17.7MB total (28.9KB/card average)

bin/check-og-build-budget.js (yarn check:og-budget) asserts these stay within budget on every build, so a future regression (e.g. a design change that balloons per-card size) gets caught rather than quietly shipped.

Testing

  • plugins/og-image/index.test.js — unit tests (yarn test) for the override-detection logic against synthetic input, no real build required
  • bin/validate-og-images.js (yarn validate:og-images) — confirms after a real build that every doc page has a correct generated image, override pages (if any) kept their own image, and every page the plugin doesn't touch (404, search, changelog, tag pages, etc.) still falls back to the site default
  • bin/generate-og-gallery.js — dev-only tool that renders a browsable grid of every generated card for visual review

Closes #4858

┆Attachments: EDU-6690 Add custom og:images

…ating og images in package.json. Update yarn.lock.
@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
temporal-documentation Ready Ready Preview, Comment Jul 10, 2026 8:37pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs PR preview links

This PR does not change any pages in /docs. If you make updates, links to the modified pages will appear here.

@Duncanma Duncanma marked this pull request as ready for review July 10, 2026 20:36
@Duncanma Duncanma requested a review from a team as a code owner July 10, 2026 20:36
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.

Update og:image to be custom per page

1 participant