OG IMAGES

Open Graph vs Twitter Card Tags: Which Do You Need?

You shared a link, and the preview came out with the wrong title, no image, or a tiny thumbnail where you expected a wide card. Nine times out of ten the cause is a missing or misplaced meta tag, and the confusion usually starts with one question: do you need Open Graph tags, Twitter Card tags, or both?

Open Graph is a set of <meta property="og:*"> tags, originally created by Facebook and documented at ogp.me, that tell any platform which title, description and image to show when a URL is shared. Twitter Cards are a smaller, X-specific set of twitter:* tags that mostly overlap with it. This article sorts out which ones are required, which are redundant, and what a minimal correct setup looks like.

What is the difference between Open Graph and Twitter Card tags?

Open Graph is the general-purpose standard that Facebook, LinkedIn, Slack, Discord, WhatsApp and iMessage-style previews read. Twitter Card tags are read only by X, and X also reads Open Graph tags when the twitter: equivalents are absent.

That fallback is the whole story. For title, description and image, the twitter: tag is a duplicate of the og: tag. The one tag with no Open Graph equivalent is twitter:card, which tells X which card layout to render.

Here is how the two vocabularies line up:

What you want to setOpen Graph tagTwitter Card tagNeeded separately?
Titleog:titletwitter:titleNo, X falls back to og:title
Descriptionog:descriptiontwitter:descriptionNo, X falls back to og:description
Imageog:imagetwitter:imageNo, X falls back to og:image
Canonical URLog:urlnoneOpen Graph only
Content typeog:typenoneOpen Graph only
Card layoutnonetwitter:cardYes, Twitter-only

Do you need both Open Graph and Twitter Card tags?

You need Open Graph tags on every shareable page, plus a single twitter:card tag. You do not need to repeat the title, description and image under the twitter: prefix unless you want X to show something different from every other platform.

Without twitter:card, X has no instruction about layout and renders the compact summary card, with a small square thumbnail beside the text. That is the most common reason a carefully designed wide image shows up as a tiny thumbnail on X while looking correct on LinkedIn.

Setting twitter:card to summary_large_image is what asks for the wide card above the text. Use summary only when you deliberately want the small thumbnail layout.

What is the minimal set of tags that works everywhere?

The minimal set is five Open Graph tags and one Twitter tag. Every one of them earns its place, and nothing else is required for a correct preview on the major platforms.

  1. og:title: the headline shown on the card, written for a person scanning a feed rather than for a search engine.
  2. og:description: one or two sentences of context that complete the title.
  3. og:image: an absolute https URL to the preview image, never a relative path.
  4. og:url: the canonical URL of the page, so shares of tracking-parameter variants collapse to one card.
  5. og:type: website for most pages and article for blog posts.
  6. twitter:card: set to summary_large_image for the wide layout.

In plain HTML the head of a page looks like this:

<meta property="og:title" content="Your page title" />
<meta property="og:description" content="One sentence that completes the title." />
<meta property="og:image" content="https://example.com/og/your-page.png" />
<meta property="og:url" content="https://example.com/your-page" />
<meta property="og:type" content="article" />
<meta name="twitter:card" content="summary_large_image" />

Notice the attribute difference. Open Graph tags use property, while Twitter tags use name. Many scrapers are forgiving about this, but a few are not, and mixing them up is a quiet source of previews that work on one platform and fail on another.

How do you set both in the Next.js Metadata API?

In the Next.js App Router you set both through the exported metadata object or generateMetadata function, and the framework renders the correct tags into the head. The Next.js documentation for generateMetadata lists the openGraph and twitter fields.

export const metadata = {
  title: "Your page title",
  description: "One sentence that completes the title.",
  openGraph: {
    title: "Your page title",
    description: "One sentence that completes the title.",
    url: "https://example.com/your-page",
    type: "article",
    images: ["https://example.com/og/your-page.png"],
  },
  twitter: {
    card: "summary_large_image",
  },
};

The twitter block contains only card. Title, description and image are inherited by X from the Open Graph values, which keeps the two vocabularies from drifting apart when someone edits one and forgets the other.

One trap to watch for: in the App Router, defining openGraph in a nested route segment replaces the parent's openGraph object rather than merging with it. If a child page sets only openGraph.title, the image from the layout can disappear. Set the full block on any page that overrides it.

Where does a per-page image come from?

This is the part that turns tedious. Tags are easy to set once, but a unique, correctly cropped image for every page means either designing each one by hand or generating it from a template at request time.

Generating images from a template works well, but it brings its own failure modes: a CSS subset that Satori supports, font loading in production, and cache behavior on the social platforms. The OG Image Generator Boilerplate from BuyCoded ships ready-made templates written to that CSS subset, bundles DejaVu Sans so text renders without a font fetch, and includes a preview page that surfaces template errors before you deploy. If you would rather start from working templates than debug Satori, the OG Image Generator Boilerplate is the shortest route.

What goes wrong when the tags are right but the preview is not?

When the tags are correct and the preview is still wrong, the cause is almost always caching or a fetch failure, not the markup. Platforms scrape a URL once and then reuse that result, so a fix on your server does not appear until the platform fetches again.

Work through these checks in order:

  • The image URL is relative. Scrapers need an absolute https URL. A path such as /og.png is silently dropped by several of them.
  • The image is behind authentication or a redirect chain. Scrapers do not log in, and long redirect chains can time out.
  • The tags are rendered client-side. Most scrapers do not run JavaScript, so tags injected after hydration are never seen. They must be in the server-rendered HTML.
  • The platform cached an older version. Each platform has its own debugger or re-scrape mechanism, and the old card persists until you force a refresh.

A quick way to see what a scraper sees is to fetch the page with curl and look for the og: lines in the raw response. If they are not in that output, no platform will find them either.

What is the most common reason people skip the fix?

The most common objection is that it is a small detail and social previews are not worth an afternoon. That is fair for an internal tool, and wrong for anything you want people to share, because the preview card is often the only part of your page that most people see before deciding to click.

The other objection is that you could build the image generator yourself. You can, and the tags above take ten minutes. The time goes into fonts, layout limits and cache debugging, which is why many developers prefer to start from templates that already pass those checks.

What should you do next?

Add the six tags above to your page template, confirm them with curl, and then decide how you will produce per-page images. If you want generated images instead of hand-made ones, open the BuyCoded catalog, pick the OG image package, and you will see the license, price and contents before you buy. More guides on previews and metadata are on the BuyCoded blog.

Frequently asked questions

Do I need twitter:title and twitter:description if I already have og tags?

No, you do not need them. When twitter:title, twitter:description and twitter:image are missing, X falls back to the matching og: values. Add them only when you want X to show different wording or a different image from other platforms. The twitter:card tag is the one you cannot skip, because it has no Open Graph equivalent.

Why does my image show as a small thumbnail on X but wide on LinkedIn?

The page is almost certainly missing twitter:card, so X renders the compact summary layout. LinkedIn reads only Open Graph tags and uses the wide format by default. Add a meta tag named twitter:card with the value summary_large_image, then re-scrape or wait for X to refresh its cached card for that URL.

Should Open Graph tags use property or name?

Open Graph tags should use the property attribute, as in property="og:title". Twitter Card tags conventionally use the name attribute, as in name="twitter:card". Some scrapers accept either, but following the convention for each vocabulary avoids previews that work on one platform and silently fail on another.

Does og:image need an absolute URL?

Yes, use an absolute https URL. Several scrapers ignore relative paths such as /og.png because they have no reliable base to resolve them against. The image must also be publicly reachable without login, and should load without a long chain of redirects, or the platform may show no image at all.

Why does my preview not change after I fix the tags?

Platforms cache the result of their first scrape and reuse it. Your fix is live on the server, but the platform has not fetched the page again. Use the platform's own debugger or sharing tool to force a re-scrape, and confirm with curl that the corrected tags appear in the server-rendered HTML.