CommunityImagegithub.com

og-image

Set up, change or check a site's Open Graph images (og:image link-preview cards) with @beeirl/og-image, which makes every page's card at build time. Also the skill other skills hand OG images to.

What is og-image?

og-image is a Claude Code agent skill that set up, change or check a site's Open Graph images (og:image link-preview cards) with @beeirl/og-image, which makes every page's card at build time. Also the skill other skills hand OG images to.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/beeirl/og-image/tree/HEAD/skill/og-image

Installed? Explore more Image skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

OG images with @beeirl/og-image

Every page gets its own link-preview card, made when the site builds: the logo at the top left and the page's heading anchored to the bottom left, on the brand's background. Long headings get a smaller size and grow upward. Nothing runs at request time, so there is no service, key or deploy step; the cards ship with the site as static files.

How it works: the layout writes a placeholder og:image (/og/<slug>.png) and the card's text in og-image:title (and optionally og-image:serif) meta tags. After the build, the package renders each card with Satori and resvg, names the file after a hash of its pixels, rewrites the page's URLs to it and removes the two meta tags. A changed heading or design gives a new URL, so link previews refresh. A placeholder without a title fails the build.

Source, README and the brand config's options: https://github.com/beeirl/og-image.

Steps

  1. Read the site. Note the framework and whether it builds static HTML; where <head> is written; every place that writes og:image or twitter:image today (afterwards exactly one place does); how the canonical URL and the page title are set; the logo as an SVG lockup; the background and heading colours; the heading font the site uses. Done when each is a file path or a value.

  2. Fonts. The renderer reads TTF, OTF or WOFF, never WOFF2. Commit Latin subsets of the site's own heading font (and the serif, and whatever font the logo's wordmark is set in) next to the site's fonts, with their licences: pyftsubset Font.ttf --unicodes='U+0020-007E,U+00A0-00FF,U+2010-2027,U+2030-203A' --layout-features='kern,liga,calt' --output-file=... Use the weight the site's headings use, usually regular.

  3. Install @beeirl/og-image from GitHub, pinned the way the project pins dependencies (a catalog entry if it has one): github:beeirl/og-image#<tag>, or the tag's full commit SHA (git ls-remote https://github.com/beeirl/og-image <tag>) where only exact pins pass.

  4. Brand config. Write og-image.config.mjs at the site's root (the folder astro.config or the build runs in). Paths are relative to it.

    /** @type {import('@beeirl/og-image').BrandConfig} */
    export default {
      background: '#FAF7F2',
      color: '#1C1917',
      logo: { path: 'src/assets/logo.svg', height: 56 },
      fonts: [{ name: 'Inter Display', path: 'src/assets/fonts/InterDisplay-Regular.ttf', weight: 400 }],
      heading: { font: 'Inter Display', letterSpacing: -0.03, lineHeight: 1.06 },
    }
    

    Add serif (and its font) only when the homepage's tagline has a serif second half.

  5. Layout. Write these once, in the layout every public page uses:

    <meta property="og:image" content="{cardImageUrl(site, pathname)}" />
    <meta property="og:image:width" content="1200" />
    <meta property="og:image:height" content="630" />
    <meta property="og:image:alt" content="{heading}" />
    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:image" content="{same URL}" />
    <meta name="og-image:title" content="{heading}" />
    <meta name="og-image:serif" content="{serif line, homepage only}" />
    

    cardImageUrl comes from @beeirl/og-image/meta, which has no dependencies; site is the canonical production origin, never the request host. The heading is the page title without the brand (Pricing | Acme becomes Pricing), and a page may pass a better one. A blog cover stays on the page; the preview is the card. Remove every other og:image and twitter:image.

  6. Build step. Astro: add ogImage() from @beeirl/og-image/astro to integrations. Any other static output (Hugo, Jekyll, Eleventy, a Next.js or Vite static export): run og-image build <output dir> after the site's build, in the same script that CI and the deploy run. A site rendered per request has no build output to process; say so and stop.

  7. Check it. Render the homepage, the shortest and the longest heading on the site with og-image render --title '<heading>' [--serif '<line>'] --out <file>.png and look at each: nothing clipped, the logo and its wordmark drawn, the heading readable at 400px wide. Then build the site: every page's og:image and twitter:image point at the same /og/<slug>-<hash>.png, which exists, and no og-image: meta tag is left. Done when you have seen the images, not when the code reads right.

Changing the design is a config edit and a rebuild. The new hashes give every card a new URL, so nothing needs purging; a platform that cached an old preview picks up the new image on its next scrape (each platform's debugger forces it sooner).

Related Skills