Link Preview Generator: Build a Card That Renders Everywhere
Generating a link preview is two jobs: emitting the right metadata on your page, and confirming the platforms actually read it. This page covers both — the markup to add, and a live check of the result.
→ Generate and verify a preview card
The Minimum Markup
Everything a preview card needs lives in your page's <head>. Server-render it; crawlers generally do not execute JavaScript.
<!-- Open Graph — used by Facebook, LinkedIn, Slack, Discord, WhatsApp, iMessage -->
<meta property="og:title" content="Your page title" />
<meta property="og:description" content="One or two sentences under 200 characters." />
<meta property="og:image" content="https://example.com/preview.png" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:url" content="https://example.com/page" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="Your Site" />
<!-- Twitter Card — controls the card shape on X -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Your page title" />
<meta name="twitter:description" content="One or two sentences under 200 characters." />
<meta name="twitter:image" content="https://example.com/preview.png" />
Three rules cover most failures:
- Absolute URLs only.
/preview.pngwill not resolve for a crawler. Use the fullhttps://URL. - One canonical value per field. If
twitter:titledisagrees withog:title, different platforms show different cards. - Publicly fetchable image. No login, no signed or expiring URL, no
robots.txtblock on the image path.
Choosing the Image
| Target | Dimensions | Notes |
|---|---|---|
| Universal default | 1200×630 | 1.91:1; works on every major platform |
| Twitter/X large card | 1200×628 | Requires twitter:card=summary_large_image |
| Square fallback | 600×600 | Used by small-card layouts and some chat apps |
Keep the file under about 5 MB, use PNG or JPEG, and put the important content away from the edges — several platforms crop. Full detail: OG image size guide.
Setting og:type Correctly
og:type changes which extra fields platforms look for. website is the safe default. Use article for posts and add article:published_time and article:author. Use product for commerce pages. The Open Graph tags reference lists the type-specific fields.
Generating Previews Programmatically
If you need preview data for many URLs — a link-sharing feature, a CMS preview pane, a moderation queue — the TryUnfurl API returns the parsed metadata and per-platform card data for a URL in one request, so you do not have to write and maintain your own crawler, parser, and fallback chain.
For a one-off batch, the bulk checker accepts up to 100 URLs and exports results as CSV.
Verify Before You Ship
Generated markup is a hypothesis until a crawler confirms it. After deploying:
- Paste the live URL into TryUnfurl — it fetches server-side with no cache, the way a real crawler does.
- Confirm every platform's card renders with the image, title, and description you intended.
- Open the
og:imageURL directly in a fresh tab to confirm it is reachable. - Only then run each platform's own debugger to clear stale caches. See how to refresh a link preview.
Related: Link preview · Open Graph checker · How to test link previews · API documentation
For more information, visit “What is Unfurling?”, our complete guide to link previewing on the internet and social media.