Menu

Capping the OG image title at 60 chars taught me that constraints are the design
πŸ“°

Capping the OG image title at 60 chars taught me that constraints are the design

DEV Community: apiΒ·InAppΒ·13 days ago
#X08kM1VU
#devtoapi#devto#dev#card#title
Reading 0:00
15s threshold

I built an OG image generator API because every agent that publishes links eventually needs a 1200x630 social card, and spinning up Puppeteer just to render one felt wrong. The hard part was never the rendering β€” it was the text.

Early versions let the title be whatever length you sent. The result was predictable: 90-char titles wrapped into four lines, overflowed the card, or got clipped mid-word depending on the font. I tried auto-shrinking the font, then tried truncating with an ellipsis, and both produced cards that looked broken in different ways.

The fix that actually worked was a hard cap: title at 60 characters, description at 120, enforced server-side, with the overflow returned in the error so the caller knows exactly what got cut. Once the limit existed, the layout became deterministic. Two lines maximum, always.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.