Every Post Draws Its Own Cover
A generative SVG system that turns a slug into cover art, with a hundred drawing families, no uploaded images and a pinned hash that catches drift.
On this page
I have a designer. It is a hash function with opinions. Every post and project on this site gets a cover drawn from its slug, in two colours, on a 600 by 400 canvas, as plain generative SVG. Nobody has to upload anything, there is no image file to manage, and publishing never waits for me to find a stock photo of a person pointing at a laptop.
A slug in, a drawing out
The drawing code is a small package with no input or output and no runtime dependencies. Give it the same slug and salt and it returns the same string. The slug is hashed, the hash seeds a tiny pseudo random generator, and the generator makes the decisions in a fixed order.
flowchart TD
A["Slug and salt"] --> B["Hash"]
B --> C["Seeded random generator"]
C --> D["Drawing family and variant"]
D --> E["Layout and second family"]
E --> F["Background, accent, flips"]
F --> G["Density, weight, camera"]
G --> H["Recipe, ready to draw"]Everything below the generator is just it being asked questions, always in that sequence. The idea fits in a few lines.
// A sketch of the idea, not the package itself.
function recipe(slug: string, salt = 0) {
const next = seededRandom(hash(salt ? `${slug}#${salt}` : slug));
const pick = <T>(list: readonly T[]) => list[Math.floor(next() * list.length)];
return { family: pick(FAMILIES), layout: pick(LAYOUTS), ground: pick(GROUNDS) };
}Tip
The fixed order is the part people skip. If a later decision consumes a random number only sometimes, every decision after it shifts, and a change to one knob repaints the world.
So the real recipe draws the second family even when the layout will only use one. It costs a number nobody looks at and keeps the rest of the cover where it was. The art, the second art, the layout and the background each get their own generator for the same reason.
A hundred families, then multiply
A family is one kind of drawing, written as one file: a function that takes the generator and a few knobs and returns shapes.
| Ingredient | How many | A taste |
|---|---|---|
| Families | 100 | contour lines, mazes, metro maps |
| Variants per family | 3 | square, circular or hex maze |
| Layouts | 14 | porthole, kaleidoscope, ring |
| Backgrounds | 12 | dots, halftone, isometric |
Many families carry a one line note on what the picture means. The randomart family hashes the page’s name and walks it across a board, the way SSH draws a key’s fingerprint. merkle draws the tree where changing one leaf changes every hash above it, which is a fair thing for a hash to be drawing. Circuit boards, a git graph and a punch card are in the drawer too. Even the slug’s initials get a turn, set in a dot matrix by the monogram family.
The variants differ in structure, so a maze really is a different maze. A ring layout can hold a second family in its hole. Then a camera turns, zooms and shifts the art, with the rotation limit calculated so a turned canvas never exposes an empty corner. All of it is applied as one transform matrix. Plain SVG does the rest.
Quality control for art nobody previews
Random art has a failure rate. A zoom can crop a sparse drawing down to nothing, and nobody is checking each cover before it goes out. So the checking moved into code.
flowchart TD
A["Family draws"] --> B{"Family happy<br/>with it?"}
B -->|"no, tries left"| A
B -->|"yes, or out of tries"| C["Apply the camera"]
C --> D{"Enough of the<br/>canvas filled?"}
D -->|yes| E["Keep the framing"]
D -->|no| F{"Much emptier than<br/>the plain view?"}
F -->|no| E
F -->|yes| G["Use the plain view"]The numbers behind those diamonds are modest. A family gets up to four tries in all. For the camera, a safeguard lays a 6 by 4 grid over the canvas and counts the cells that contain art. If framing left under half the grid filled and lost a good part of what the plain view showed, the plain view wins.
Then there’s a test harness, which draws every family 600 times and holds it to a budget: nine draws in ten under 30,000 characters and under 400 elements, no NaN anywhere, no text elements, nothing flung far off the canvas. The families that draw computations get checked as computations. The glider has to move, the busy beaver has to halt and the sorting networks have to sort. Decorative art that is also correct is a niche I’m happy to occupy.
Two posts must not wear the same shirt
With enough posts, two slugs will eventually draw covers that look alike. Hence the salt, a small integer that gives a slug a different recipe. Each cover has a signature made of its family, variant, layout, second family and background. The site walks all posts and projects in creation order and gives each one the first salt whose signature is unused and whose family hasn’t appeared among the previous 24 of its kind.
Nothing stores the salts. They are recomputed from the published lists, which keeps the database out of the art business and has one honest consequence. I measured it on a test set of 385 slugs.
| Change to the list | Moved another cover |
|---|---|
| add a newest item | 0 of 600 tries |
| remove one post | 93 of 201 trials |
| remove one project | 91 of 184 trials |
I accepted that. The art is arbitrary, and a cover that changes after an unpublish harms nobody’s weekend.
A hash that catches drift
The promise “same slug, same picture” dies quietly. Someone tidies a family, a rounding changes, and a hundred covers shift by a pixel with every test still green.
So one test renders every family in every layout on every background, plus the other two variants of each family:
It hashes all of those results and pins a single hash over them. Change what any of them draws and it fails. The fix is deliberate: bump the cover version, which sits in every cover URL and so tells browsers to fetch the new art, then record the new hash. The pin covers one recipe per combination, with the finer behaviour left to the per family tests. The run took 80 seconds when I measured it on 6 November 2026, a reasonable price for never wondering.
Generative SVG that moves only when asked
The served file is a still image. Its elements carry inert data- attributes that say how a part would move: spin, pulse, trace, march along a line. An ordinary renderer ignores them, so one file works in an image tag, the feed and the sitemap, and the offline copy of the site stores it like any picture. Movement is something a small script adds to a copy.
sequenceDiagram
participant P as Card on the page
participant S as Small script
participant F as Cover file
P->>S: your pointer rests on it
S->>F: fetch the SVG
F-->>S: the still image
S->>S: parse in an inert document
S->>S: keep only allowed elements
S->>P: lay the live copy on top
Note over P: plays once, then restsThe allowlist holds 17 SVG elements, and everything else is dropped before the copy touches the page. It plays once for 3.2 seconds and never loops. The wait for the pointer to stop earns its keep: on a sweep across 17 real covers in Chromium, it took the long tasks from 2754 ms to none. With reduced motion turned on, the script attaches nothing and the pictures stay pictures.
All of this lives in tdaweb, the code behind the site. To see what the hash thinks of a title, publish something. It will have an opinion before you do.