Skip to main content
Guide 7 min read

How to Set Up Open Graph Tags So Your Links Look Good on X, Facebook and LinkedIn

You share a link and the preview shows a gray box, a random logo or the wrong title. It looks careless, and people scroll right past it. Open Graph tags fix that. They tell X, Facebook and LinkedIn which title, description and image to show when someone shares your page.

This guide shows you how to set up Open Graph tags from start to finish. You’ll get the tags you need, the right image size, a code sample, the mistakes that break previews and a way to test everything before you post.

What Open Graph tags are

Open Graph is a set of meta tags that Facebook created. You place them in the head of your page. When someone shares your URL, the platform fetches the page, reads the tags and builds a preview card. No tags, and the platform guesses. It usually guesses badly.

Here’s a bonus. Other apps read the same tags. WhatsApp, Slack, Discord and iMessage all use them, so one clean setup improves your previews almost everywhere.

The tags you need

Six tags do most of the work:

  • og:title is the headline on the card.
  • og:description is the short text under it.
  • og:image is the full address of the preview image.
  • og:url is the main address of the page.
  • og:type is website for most pages and article for blog posts.
  • og:site_name is your brand name.

Add an image description for people who use screen readers, and one X tag for the card style. A full set looks like this:

<meta property="og:title" content="Your Page Title">
<meta property="og:description" content="One short sentence about the page.">
<meta property="og:image" content="https://example.com/images/card.jpg">
<meta property="og:image:alt" content="Short description of the image">
<meta property="og:url" content="https://example.com/page">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Your Brand">
<meta name="twitter:card" content="summary_large_image">

Don’t want to type all that? Our Open Graph generator builds the whole block from a simple form.

How X, Facebook and LinkedIn read them

The three platforms don’t behave the same way, and that’s where people get confused.

Facebook and LinkedIn read Open Graph tags and ignore the X tags. X reads its own twitter tags first, then falls back to Open Graph for anything missing. So you don’t need a full second set for X. You need one tag, twitter:card, set to summary_large_image. Without it, X usually shows the smaller summary card with a tiny thumbnail.

The result is simple. Write the Open Graph tags once, add the card tag and all three platforms have what they need.

Get the image right

The image does more than any other tag. A bold picture stops the scroll, and a bad crop makes you look sloppy. Use these rules:

  • Make it 1200 pixels wide and 630 pixels tall. That 1.91 to 1 shape works on all three platforms.
  • Keep the file under 5 MB. Smaller loads faster and fails less.
  • Save it as a JPG or PNG. Not every platform reads WebP, and none of them read SVG.
  • Use a full address that starts with https. Relative paths fail.
  • Skip base64 data addresses. The crawlers won’t read them.
  • Keep text and logos near the center. X and others crop the edges a little.

Small images cause trouble too. On Facebook, an image narrower than about 600 pixels often shows as a small thumbnail beside the text instead of a big card.

Write a title and description that fit

Each platform trims text at a different point. Keep titles near 60 characters and descriptions near 150, and put the key words first. Paste your draft into our character counter before you commit.

Your social title doesn’t have to match your page title. The page title serves search, and the social title serves a human scrolling a feed. Make it clear and a little warmer.

One technical catch. Quotes and ampersands break the tag if you leave them raw inside the content value. Escape them first. Our HTML encoder decoder does it in one click.

How to add the tags to your site

Follow these steps in order:

  1. Pick or design a 1200 by 630 image and upload it to your site.
  2. Write a title and a description for the page.
  3. Generate the tags with the Open Graph generator.
  4. Paste them into the head of your page. On WordPress, plugins like Yoast SEO and Rank Math have social settings for this. Shopify, Webflow and most site builders have a field too.
  5. Check that the tags appear in the HTML your server sends. Most share crawlers don’t run JavaScript, so tags added by a script get missed.
  6. Publish, then test the link.

Use one source for your tags. A theme and a plugin that both print Open Graph tags create duplicates, and the platform may pick the wrong one.

Test and refresh your previews

Never trust a preview you haven’t seen. Each platform has a way to check it:

  • Facebook. The Sharing Debugger shows what Facebook sees and lets you scrape the page again.
  • LinkedIn. The Post Inspector does the same and refreshes the cached card.
  • X. Paste the link into a draft post and look at the card. X no longer offers a reliable standalone validator.

Here’s the thing about caching. Platforms store a preview after the first share. If you fix the image later, old shares can keep showing the old card. Run the debugger to force a refresh. A new file name for the image helps too, because the platform treats it as a new picture.

Mistakes that break previews

These slips cause most broken cards:

  • A relative image path like /images/card.jpg. Use the full address.
  • An image blocked by robots.txt or hidden behind a login. The crawlers named facebookexternalhit, LinkedInBot and Twitterbot must reach the file. Check your rules with our robots.txt generator, and read our guide on robots.txt vs noindex if blocking confuses you.
  • Redirects on the page or the image address. A long chain can fail, and og:url should match the final address. Trace the path with our redirect checker.
  • Spaces or special characters in the image address. Encode them with our URL encoder decoder.
  • Duplicate tags from a theme and a plugin.
  • Tags placed in the body instead of the head.
  • Forgetting to refresh the cache after a change.

A checklist before you share

Run through this list once per page:

  1. The image is 1200 by 630, under 5 MB and saved as JPG or PNG.
  2. The image address is full and starts with https.
  3. The title is near 60 characters and the description near 150.
  4. Quotes and ampersands are escaped.
  5. The tags sit in the head of the HTML your server sends.
  6. Only one source prints the tags.
  7. The twitter:card tag is set to summary_large_image.
  8. You tested the link in the Facebook debugger, the LinkedIn inspector and an X draft post.

The short version

Add og:title, og:description, og:image, og:url and og:type to the head of your page, then add twitter:card for X. Use a 1200 by 630 image with a full https address. Keep text short, escape special characters and test every link in each platform’s tool before you share it.

Pick your most shared page and run it through the Facebook debugger today. If the card looks wrong, you now know where to look.

Free browser based tools on Black Claaw to build tags, check text length, escape code and trace broken paths.

View all tools

Advertisement