Menu

One Object, Three Outputs: Keeping og:*, twitter:* and JSON-LD in Sync in Next.js
📰

One Object, Three Outputs: Keeping og:*, twitter:* and JSON-LD in Sync in Next.js

DEV Community: typescript·Abid Ali·4 days ago
#zclEpbRh
#devtotypescript#devto#dev#description#const
Reading 0:00
15s threshold

Open a few production pages and compare three things in the <head> : the meta description, og:description , and the description inside the JSON-LD block. On a lot of sites they say three slightly different things. The meta description was written at launch, the Open Graph text was fixed after someone complained about a LinkedIn card, and the JSON-LD was pasted from a schema generator and never touched again.

Nobody sees all three at once, so the drift goes unnoticed. Search engines read one set, chat and social apps read another, and the same page ends up introducing itself in different words depending on where someone meets it.

This post shows the setup I use on Next.js projects to stop that: one typed object per page, two small functions that turn it into Metadata and JSON-LD, and a script that catches drift on the live HTML.

Who reads what

It helps to be clear about the consumers first, because they are not interchangeable:

Open Graph tags ( og:title , og:description , og:image , og:url ) are what…

Continue reading — create a free account

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