Dev.to WebDev 🛠 Dev 👁 0 📖 7 min read

How to generate abstract OG images for blog posts and docs

Most blogs end up with one of three cover images: a stock photo that has nothing to do with the post, a screenshot that's out of date three releases later, or the same logo card on every page. None of them tell a reader

How to generate abstract OG images for blog posts and docs

Most blogs end up with one of three cover images: a stock photo that has nothing to do with the post, a screenshot that's out of date three releases later, or the same logo card on every page. None of them tell a reader scrolling past on LinkedIn or Slack which post this is.

An abstract cover fixes that without anyone opening a design tool per post. It's a colour, a geometric motif and the title, nothing else. Because it has no photo and no UI in it, it reads at thumbnail size and never goes stale. And because it's a system rather than a picture, it can be generated for every blog post, docs page and changelog entry you have.

Here is the system we built, the rules behind it, and how we generated the whole set below with an AI agent through the bannx MCP server.

Six abstract OG images from one template: a teal docs card with stepped bars, an amber changelog card with a dot grid, a rose essay card with rings, a blue tutorial card with dots, a lime help-center card with steps and a charcoal release-notes card with rings

What makes an abstract cover work

A good abstract cover is mostly restraint. Five rules carry it:

  1. One base colour per card. Not a palette, one colour. Every other shade on the card is derived from it, so the card always looks intentional, whatever colour you pick.
  2. One motif from a small set. Three or four shapes, each built from one repeated element: rings, bars, dots. A reader learns the set after a few posts, and the set is what makes the covers look like your covers.
  3. The title is the only real text. Big, short, left-aligned, two or three lines. A small section label above it and a site name below are the only extras.
  4. The motif never competes with the title. Keep it in one zone (the right half, a corner) and keep it lighter or lower in contrast than the text.
  5. Text colour follows the background. White on indigo, near-black on amber. Pick it from the colour, never by hand.

The colour and the motif carry meaning too. Give each section of your site a fixed pair and the cover tells the reader where they are before they read the title:

Section Colour Motif
Docs Teal Steps
Changelog Amber Dots
Essays Rose Orbits
Tutorials Blue Dots
Help center Lime Steps
Release notes Charcoal Orbits

Build it as a template, not a picture

The trick that makes this scale is that nothing on the card is drawn by hand. The template is 1200 × 630 (the Open Graph size) and has five inputs:

Variable Example What it drives
title How to generate abstract OG images The headline, shrinking to fit if it runs long
kicker Guide The small label above the title
site bannx.com/blog The footer
color #3B2DD9 The background and every tint in the motif
motif orbits, steps or dots Which motif is shown

Everything else is computed from those.

The motifs are loops

Each motif is one shape repeated over a list. The rings are a single ellipse layer with a repeat over eight items. Its size, position and colour are formulas of the item number i, so ring 0 is the biggest and darkest and ring 7 the smallest and palest:

repeat:  rings          (a hidden list: 0, 1, 2 … 7)
w, h:    1240 - i * 140
x:       1180 - (1240 - i * 140) / 2
y:       680 - (1240 - i * 140) / 2
fill:    {{ tint(color, 0.08 + i * 0.1) }}

The steps are one rectangle repeated the same way, each bar 60 px taller than the last. The dots are a loop inside a loop: ten rows, each repeating a dot nine times, the dot growing with its column and fading with its row. Change the formula and you have a new motif; there are no hundred hand-placed shapes to maintain.

Every shade comes from one colour

tint(color, 0.3) mixes the base colour 30% toward white, and shade() mixes it toward black. Because the motif only ever uses tints of the background, any colour you pass in gives a card that looks designed: indigo gives lavender rings, amber gives peach dots, charcoal gives greys. The full list of colour helpers is in the template expressions reference.

Text colour picks itself, with the right threshold

The title, label and footer all use one expression:

{{ isLight(color, 0.3) ? '#111827' : '#ffffff' }}

The first version used isLight(color) with its default threshold of 0.5, and the amber changelog card came out with white text on #F59E0B. Amber's relative luminance is about 0.44, so it counted as "dark", but white on it is a contrast of roughly 2:1, well under the 4.5:1 that WCAG asks for. Near-black on the same amber is about 8:1. The crossover point where black and white text have equal contrast sits around a luminance of 0.2, so a threshold of 0.3 keeps mid-tones like amber and lime on dark text and sends indigo, teal and rose to white. If your covers ever look washed out, check this before anything else.

The motif switch

Each motif lives in its own group with a Show if condition: motif === 'orbits', motif === 'steps', motif === 'dots'. Exactly one is visible per render, and a site can set it per section, per post, or leave it on the default.

Generate the set with an AI agent

We didn't build this in the editor. An AI agent built it through the bannx MCP server, and the brief was close to what you've just read: a 1200 × 630 cover, colour-driven tints, three looping motifs, automatic text colour.

The agent's work came down to a handful of tool calls:

  1. get_guide with creative-authoring and template-expressions, to learn the operation vocabulary and the colour helpers.
  2. template_create with the variables, three sample value sets and every layer in one batch.
  3. template_render once per sample, to look at the result.
  4. template_apply_ops to fix what the renders showed: the groups started with a white fill that covered the background, and the amber card had white text (the threshold problem above).
  5. template_publish to make the template page public.

Rendering a cover is one call with the post's values:

{
  "tool": "template_render",
  "arguments": {
    "templateId": "TEMPLATE_ID",
    "format": "png",
    "variables": {
      "title": "What shipped in November",
      "kicker": "Changelog",
      "site": "example.com/changelog",
      "color": "#F59E0B",
      "motif": "dots"
    }
  }
}

Every render costs one credit, and the agent sees each image it makes, so the loop of render → look → fix is the same loop a designer runs, just faster. Two rounds of fixes was all this template needed.

You can do the same without an agent. Open the template, change the fields on the right and the preview updates as you type:

The public template page for the abstract cover: a large indigo preview with rings on the left, and on the right a form with a size picker and Title, Section and Site fields

The same template page after editing the form: the preview is now an amber changelog card with a dot grid, and the form shows Title "What shipped in November", Section "Changelog", Colour "#F59E0B" and Motif "dots"

One design, every size

A blog cover on your own site is often 16:9, an OG image is 1.91:1 and a social post is square. The motif groups are pinned to the right and bottom edges and stretch with the canvas, so the same template renders at other sizes without a second design. Pass size on the render:

{ "templateId": "TEMPLATE_ID", "size": "1080x1080", "variables": { "motif": "dots", "color": "#F59E0B" } }

The amber changelog cover re-rendered as a 1080 × 1080 square: the title sits top-left and the dot grid fills the right side

The teal docs cover re-rendered at the 1600 × 840 blog-cover size with the stepped bars anchored to the bottom-right corner

The cover at the top of this post is the same template at 1200 × 675. See rendering at another size for the presets.

Put it in your og:image tag

To give every page its own cover without rendering anything ahead of time, use a signed image URL. It has no API key in it, it can't be edited (changing title= breaks the signature), and each distinct URL renders once on its first open and is served from storage after that:

<meta property="og:image"
  content="https://bannx.com/r/TEMPLATE_ID?color=%230F766E&kicker=Docs&motif=steps&title=Authentication%20and%20API%20keys&sig=SIGNATURE">

Sign them from your server or build script, up to 500 at a time, with POST /api/v1/templates/:id/signed-urls (or the template_sign_urls MCP tool). Map each section of your site to its colour and motif in that script, and the table at the top of this post becomes code:

const SECTION_STYLE = {
  docs:      { kicker: "Docs",      color: "#0F766E", motif: "steps" },
  changelog: { kicker: "Changelog", color: "#F59E0B", motif: "dots" },
  blog:      { kicker: "Essay",     color: "#E11D48", motif: "orbits" },
};

const rows = pages.map((p) => ({
  variables: { title: p.title, site: "example.com", ...SECTION_STYLE[p.section] },
}));

The OG image API guide walks through the signing call, a Node script that chunks a long page list, and snippets for Next.js, Nuxt, Astro and plain HTML. The signed image URLs docs cover the details.

A checklist before you ship

  • Keep the title under about 60 characters. The template shrinks long titles to fit, but a three-line title at 64 px is what reads in a feed.
  • Check contrast on your lightest and darkest section colours. Those are the two that break.
  • Leave the motif out of the top-left. Some platforms crop the edges or lay a play button or domain label over the card.
  • Decide the colour and motif per section, not per post. Randomness looks lively for a week and then looks like nobody decided.
  • Test the URL in a link preview debugger before the first share. Platforms cache the first image they fetch.

Try it

The template is public: open Abstract Cover: Orbits, Steps, Dots, change the title and colour, and download a PNG, or remix it into your space and swap the motifs for your own. To have an agent make yours, connect the MCP server and hand it the five rules above.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.