Fixing link previews: why your posts now show up right on WhatsApp and LinkedIn
Share a blog post link on WhatsApp, LinkedIn or Slack, and you expect to see that post's own title, its excerpt, and its photo in the preview card. For a long time, blogs built on a single detail page for every article couldn't promise that, and it's worth explaining why, because the fix isn't obvious.
The problem: one file, many posts
A page like post.html?slug=your-post is one HTML file on disk. Every post uses it, and which post loads is decided by JavaScript reading the slug from the URL, after the page has already reached the browser. That works perfectly for a visitor: the script fetches the right row and fills in the title, image and body.
It does not work for a link preview. Facebook, X, LinkedIn, Slack, WhatsApp and iMessage do not run your JavaScript when they fetch a shared link. They read the raw HTML you served and stop there. If that raw HTML only contains generic tags like "Kreova Blog" and no image, that is exactly what shows up, no matter how good the client-side code is.
"But the page updates the title and image once it loads, why doesn't the preview show that?"
Because by the time your JavaScript runs, the crawler has already left. It took a snapshot of the empty shell and moved on.
The fix: a lookup at the server, not the browser
The real fix is to make the server answer differently depending on which post is being requested, before any HTML is sent out. A link-preview route does exactly that: it is told which page, which table, which query parameter to read, and which columns become the title, description and image. On every request, the row is looked up first, and the <title>, description, canonical link, Open Graph and Twitter tags are rewritten directly into the HTML that gets served, image included.
Crucially, this is not a trick layered on top of the client-side script. Both now agree: a crawler that never runs JavaScript gets the correct tags because the server rewrote them, and a browser that does run JavaScript gets the same correct tags a second time, for in-app navigation and the tab title.
What changed for readers
Nothing about how you write or publish a post changed. But now:
- Sharing a post on LinkedIn or WhatsApp shows its real title and excerpt, not a generic one
- The featured image appears in the preview card, not a blank box
- Search engines see accurate, article-specific metadata for every URL, not one shared description across the whole site
The honest limitation
This approach depends on the table being readable and the route being told exactly which page maps to which record. It also only covers pages built this way, detail pages that load a single row from a query parameter. A page that never loads a specific record from the database has nothing to route, and stays on its generic tags, which is the right outcome for it anyway.
If you're building something similar, the lesson generalizes: anything that decides what a crawler sees has to happen before the HTML leaves the server, not after it arrives in the browser. Client-side rendering is for people; server-side rendering, even a narrow, targeted slice of it like this, is for everyone else reading your HTML without a browser attached.

Comments
Loading comments…