SpunkArt
Websites, APIs and search

How link previews work: Open Graph tags explained

When you paste a link into a chat or a social post, the app fetches the page and builds a small card with a title, a line of text and an image. Open Graph tags let you decide what goes on that card.

What happens when someone shares your link

  1. The app’s server requests your page, usually with its own user agent and without running your JavaScript.
  2. It reads og: meta tags from the HTML head. If they are missing it falls back to the title, the description, or the first image it finds.
  3. It downloads the image, resizes or crops it, and stores the result in a cache.
  4. Everyone who later sees the link sees the cached card.

Step 1 explains a common surprise: tags injected by client-side JavaScript are often invisible to preview bots. Put the tags in the HTML your server sends.

The minimum set

<meta property="og:title" content="How to repot a cactus">
<meta property="og:description" content="When to do it, which soil to use, and how to avoid the spines.">
<meta property="og:image" content="FULL-ADDRESS-OF-IMAGE.png">
<meta property="og:url" content="FULL-ADDRESS-OF-PAGE">
<meta property="og:type" content="article">
<meta name="twitter:card" content="summary_large_image">

Replace the placeholders with absolute addresses, including the scheme. A relative path such as /img/card.png does not work in og:image, because the bot has no page context to resolve it against. Note the attribute difference too: Open Graph tags use property, while the card-type tag uses name.

Sizing the image

Large preview cards are wide rectangles. A common choice is 1200 × 630 pixels, a ratio of about 1.91 to 1 (1200 ÷ 630 = 1.905). Some apps crop to a square or a different ratio on certain screens, so keep text and faces inside a central safe area and away from the edges.

CheckWhy
Use PNG or JPEGThe most widely supported formats for preview bots
Keep the file reasonably smallSome bots give up on very large images
Make text largeCards often display at thumbnail size on phones
Serve it publiclyAn image behind a login or blocked by robots rules cannot be fetched

Previewing without a tool

You can see what a bot sees with curl. Fetch the raw HTML and pull out the tags:

curl -sL example.com/guides/repot-cactus | grep -i 'og:\|twitter:'

If nothing prints, the tags are not in the server response. Then open the image address on its own in a browser to confirm it loads. Finally, paste the link into a private chat with yourself in the app you care about.

Why the old preview keeps appearing

Apps cache cards, sometimes for days. Changing the tags does not update cards already generated. Many large platforms offer a sharing debugger that lets the owner ask for a fresh fetch. Another workaround is adding a harmless query string to the URL so the app treats it as a new link.

Common mistakes

  • Same og:title and image on every page, so every share looks identical.
  • Image address pointing at a staging server that later disappears.
  • Description copied from another page and no longer accurate.

Questions

Do Open Graph tags help search rankings?

They are for sharing, not ranking. Their value is a clearer card that more people click.

Do I need separate tags for every app?

Most apps read Open Graph. The twitter:card tag chooses the card layout on platforms that support it; other twitter: tags usually fall back to the og: values.