Όλα τα άρθρα
21 Νοεμβρίου 2026

Open Graph and Twitter card tags: what to set and how to test them, 2026

Set og:title, og:type, og:image and og:url, add twitter:card, then test with the Facebook Sharing Debugger and an unsent post on X.

Open laptop with a blank white screen on a bright desk beside a glass of water, ready for a link preview test

The short answer

Set four Open Graph tags on every page: og:title, og:type, og:image and og:url. Add og:description and og:image:alt as well. Then add twitter:card to pick the layout X shows. To test, run the URL through the Facebook Sharing Debugger, the LinkedIn Post Inspector, and compose an unsent post on X. As of November 2026, that covers the platforms most teams care about.

What these tags do

Link previews are built by crawlers. When someone pastes your URL into a post or a chat, the platform fetches the page and reads its <head>. Meta's sharing guide says that without Open Graph tags, the Facebook crawler guesses the title, description and preview image. A guess can land on a cookie banner image or a menu label.

The Open Graph protocol started at Facebook and is now read far beyond it. Each tag is a <meta> element with property and content attributes in the page head. X adds its own twitter: tags, mainly to choose a card layout. The two sets overlap, so you write the Open Graph set once and add a small Twitter set on top.

Before you start

Get four things in place before you touch any markup:

  • A canonical URL for each page. og:url is the page's permanent ID, so decide it first. Our guide to canonical URLs covers how.
  • One image per page, at its own URL. Platforms cache images by URL, which matters in the testing section.
  • Tags in the server-rendered HTML. Crawlers read the response they get. If your tags are injected after the page loads in the browser, many crawlers never see them. On Next.js, generateMetadata renders them on the server.
  • A public page. Crawlers cannot log in, so a page behind a login shows no card.

Step-by-step: the tags to set

1. The four required properties

The protocol states that every page needs og:title, og:type, og:image and og:url. In the protocol's words, og:url is "the canonical URL of your object that will be used as its permanent ID in the graph."

<meta property="og:title" content="Open Graph and Twitter card tags" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://example.com/blog/open-graph-tags" />
<meta property="og:image" content="https://example.com/og/open-graph-tags.png" />

Meta's guide adds two details. Keep og:url clean: no session variables and no tracking parameters. And keep og:title to the article title, without site branding. If you leave out og:type, it defaults to website, which is fine for a home page and wrong for an article.

2. Description and image alt text

Add og:description, one to two sentences according to the protocol. Meta describes the same field as a short summary shown below the post title. Write it as the answer to what the page is about, not as a keyword list.

Then add og:image:alt. The protocol is direct: "If the page specifies an og:image it should specify og:image:alt." It describes the contents of the picture, not a caption. For writing good alt text, see image formats and alt text.

<meta property="og:description" content="Which tags to set for link previews, and how to test and refresh them." />
<meta property="og:image:alt" content="Diagram of a page head with Open Graph tags feeding a link preview card" />

3. Choose and publish the image

Use an absolute HTTPS URL for og:image. Meta recommends setting the image's width and height explicitly so that it loads properly the first time it's shared, and lists og:image:type values of image/jpeg, image/gif and image/png.

<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:type" content="image/png" />

On size: a landscape image of 1200 by 630 pixels is a common starting point. It is a convention, not a rule. The pages we fetched for this article do not set one mandatory size, so treat it as a default and check the result in the preview tools.

One more rule matters here. Meta states that images are cached by URL and "won't be updated unless the URL changes." So never overwrite og/post.png and expect the preview to change. Publish a new file, such as og/post-v2.png, and point the tag at it.

4. Add twitter:card and only what must differ

On X, the twitter:card tag selects the layout. The two common values are summary_large_image, a full-width image that suits most article pages, and summary, a small square thumbnail. Two other values, player and app, have extra requirements. See X's own card documentation before using them.

<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image:alt" content="Diagram of a page head with Open Graph tags feeding a link preview card" />

Set platform-specific tags only when the X preview must differ from the Open Graph one. Nuxt SEO's guide to Twitter cards frames it the same way. One caution: we could not load X's documentation when preparing this article, so we do not state X's image file-size or minimum-pixel limits here. Check them in X's current docs before you ship a large image.

5. Locale tags for translated pages

If a page exists in more than one language, set og:locale in language_TERRITORY form, such as es_ES. The default is en_US. List the other languages with og:locale:alternate. Each translated page should carry its own og:title, og:description and og:url, not copies of the English ones.

How to test the tags

Test in this order, because each step catches a different kind of failure.

Check the raw HTML first

Fetch the page the way a crawler does and read the <head>. Meta publishes the crawler's user agent, facebookexternalhit/1.1, and suggests loading your URL with that user agent to see how your server responds. If the tags appear for a normal browser but not for the crawler, your server treats bots differently. Also confirm the server supports gzip and deflate encodings, which Meta's guide lists as a requirement.

Facebook Sharing Debugger

Enter the URL in the Sharing Debugger. It shows which tags the crawler scraped, plus errors and warnings, and it triggers a fresh scrape after you fix your HTML. It needs a Facebook login.

LinkedIn, Discord and X

The LinkedIn Post Inspector and Discord's link preview are listed as testing tools in the Nuxt SEO guide. For X, the same guide suggests composing a post without sending it, which shows you the preview. Our fetch of X's documentation failed, so this is the only X test we describe. Do not rely on a card validator page without confirming it still exists.

Refreshing a stale preview

Platforms cache. If the preview is wrong after you fixed the tags, work through these in order:

  1. Confirm the live HTML has the new tags, and clear your own CDN or site cache.
  2. Re-scrape in the Sharing Debugger and the LinkedIn Post Inspector.
  3. If only the image is stale, change its URL, because the cache key is the URL.
  4. Remember that a post already shared may keep its old preview.

Re-scraping only fixes stale caches. If the tags are missing or the crawler is blocked, the same broken result comes back.

Common mistakes

  • Tracking parameters in og:url. Meta says to use the canonical, undecorated URL.
  • Site name inside og:title. Put the brand in og:site_name instead.
  • Overwriting the image file. The cache is keyed by URL, so the old image keeps showing.
  • A relative image path. Use an absolute HTTPS URL.
  • A blocked or private image. Nuxt SEO's checklist for missing cards names pages that need a login and images blocked by robots.txt. Our post on what robots.txt controls explains the second one.
  • Duplicate tags. The protocol says the first tag, top to bottom, wins when values conflict, so a plugin that adds a second og:image can be ignored or can override yours depending on order.
  • Missing alt text. The protocol asks for it whenever og:image is set.

If you want a second pair of eyes on previews across a whole site, that is part of our SEO and AEO work.

Frequently asked questions

Do I need Twitter card tags if I already have Open Graph tags?

Set twitter:card explicitly, because it selects the layout X shows. Add other twitter: tags only where the X preview must differ from the Open Graph one. Check X's current documentation for how it falls back to Open Graph values.

Which Open Graph tags are required?

Four: og:title, og:type, og:image and og:url, according to the Open Graph protocol. In practice, add og:description and og:image:alt as well.

Platforms cache images by URL. Meta states that an image will not update unless its URL changes, so publish the new image at a new URL and re-scrape the page in the Sharing Debugger.

What size should the og:image be?

No source we fetched sets one mandatory size. A 1200 by 630 pixel landscape image is a common starting point, and Meta recommends setting the width and height tags explicitly so the image loads properly the first time it is shared.