Preferences

Privacy is important to us, so you have the option of disabling certain types of storage that may not be necessary for the basic functioning of the website. Blocking categories may impact your experience on the website. More information (Cookie Policy)

Open Graph Tags: How to Set Them Up and Test Your Social Previews

Learn which Open Graph tags to add, the image size to use (1200 x 630), how to set them in HTML or frameworks, and how to test your link previews.

Published on
19/11/2026
Updated on
19/11/2026
Reading time
21 min
Open Graph Tags: How to Set Them Up and Test Your Social Previews

Tools

On this page

In short

Open Graph tags are meta tags in the head of a page. They tell Facebook, LinkedIn, Slack, WhatsApp and other apps which title, description and image to show when someone shares your link. Put four properties on every page: og:title, og:type, og:image and og:url. Use a full image URL at 1200 x 630 pixels, then check the page in Facebook's Sharing Debugger after every change.

Want to go further? Ask

Quick quiz

Which way of finding customers online fits you best?

Question 1 of 425%
How do your customers find businesses like yours?

What Open Graph tags are and what they change

Open Graph is a small protocol. It lets any web page describe itself to the platforms that show it. The Open Graph protocol site (ogp.me) defines the properties, their meaning and how to write them in the head of your HTML.

When someone pastes your link into a post, a chat or a message, the platform fetches the page and looks for these tags. If it finds them, it builds a card with your title, your description and your picture. If it does not, it guesses. Meta says so in its sharing guide for webmasters: without these tags, its crawler uses internal heuristics to make a best guess about the title, the description and the preview image.

A guess is often bad. The platform may pick a menu label as the title, a logo as the image, or the first sentence of a cookie banner as the description. You lose control of the first thing a reader sees.

Open Graph protocol website showing the core properties of a page
The official Open Graph protocol site lists the required properties and their meaning.

Open Graph does not set your position in Google. It sets how your link looks when it is shared. A card with a clear headline and a sharp picture is easier to click than a bare URL. That is the reason to care. A shared link that gets clicked sends people to your page, and some of them link to it later.

Open Graph is not the meta description

Many people treat the two as the same. They are different tags with different jobs. The meta description is written for search results. The Open Graph description is written for the card that a platform builds when someone shares the page. You can use the same sentence for both, but you do not have to, and the image has no equivalent in the meta description at all.

The four ways a card goes wrong

Most broken cards come from one of four causes. The tags are missing, so the platform guesses. The tags are present but point to a relative image path that the platform cannot load. The tags are duplicated, so two sets compete. Or the tags exist only after JavaScript runs, so the crawler never sees them. Each cause has a clear test, and we cover all four in the sections below.

The tags every page needs

The Open Graph protocol lists four required properties for every page. Put these in the head of every indexable page, including your blog posts, category pages and product pages.

Minimum tags for every page

  • og:title, the headline of the card
  • og:type, the kind of object, usually website or article
  • og:image, a full URL to a picture that represents the page
  • og:url, the canonical URL of the page
  • og:description, one or two sentences under the headline
  • og:site_name and og:locale, which name the site and set the language

Two of the required tags deserve a closer look. The og:type tag is easy to skip, and the default matters. Meta says that if you do not specify a type, the default is website. That is fine for a home page, but a blog post should say article, so that the platform treats it as an article.

The og:url tag is the permanent ID of the page in the protocol's model. Use the canonical URL, the one you want people to share. If your page has a canonical tag, og:url should match it. If the two disagree, you split the share count of one page across several addresses.

The og:locale tag defaults to en_US when you leave it out, according to the protocol. Set it on pages in other languages, such as fr_FR for a French page, so the platform does not assume English.

Isometric illustration of a web page card linked by blue lines to abstract share nodes
A page turned into a shareable card: one link, one image, one headline.

What each tag does, with examples

The table below lists every tag you are likely to use. The required column follows the protocol. The rest are recommended or optional, but they cost nothing and they make the card more predictable.

TagWhat it controlsRequired?Example value
og:titleThe headline of the cardYesOpen Graph Tags: How to Set Them Up and Test Social Previews
og:typeThe kind of object, website or articleYesarticle
og:imageThe picture in the card, as a full URLYeshttps://www.example.com/images/open-graph-tags.jpg
og:urlThe canonical address of the pageYeshttps://www.example.com/blog/open-graph-tags
og:descriptionOne or two sentences under the headlineRecommendedA short summary of what the reader gets
og:site_nameThe name of the whole siteOptionalExample Shop
og:localeLanguage and region, default en_USOptionalfr_FR
og:image:width and og:image:heightPixel size of the image, so the platform can reserve spaceRecommended1200 and 630
og:image:altText description of the imageShould be set with og:imagePreview card of an article about Open Graph tags

Write the headline for the card, not only for the search result

The og:title tag can differ from your SEO title. The SEO title has to fit the search results, and it often ends with your brand name. Facebook's guidance is to leave branding, such as the site name, out of the og:title. Put the brand in og:site_name instead, where the platform can place it separately.

Keep the headline short enough to read in one line on a phone. Use the words a reader would say out loud, not the keyword list. If the page targets a query like "open graph tags", keep that phrase near the start of the headline, and make sure the headline still makes sense on its own.

Note

Your SEO title and your og:title can be different on purpose. Keep the SEO title for Google and write a plainer, more direct headline for the card. What matters is that the card matches what the page promises.

Write the description in one or two sentences

The protocol describes the og:description as one to two sentences. Write it as a promise of what the reader gets, not as a summary of the page structure. "Five checks you can run in ten minutes" works better than "This article is about Open Graph tags and their use in HTML pages".

Images: the size, ratio and weight that avoid cropping

The picture is the part people look at first. A badly sized image gets cropped, stretched or replaced by a small thumbnail. The rules below come from Meta's guide for Facebook, which is the strictest of the platforms we checked on this point. Other platforms use similar sizes, but check each one before you rely on it.

Meta recommends an image of at least 1200 x 630 pixels for the best display on high-resolution screens. It asks you to keep the image as close as possible to a 1.91:1 aspect ratio, so that the whole picture shows in the feed without cropping. Images at 600 x 315 pixels still show, but much smaller. The absolute minimum allowed is 200 x 200 pixels, and the file must not exceed 8 MB.

Facebook image specs

1200 x 630recommended pixel size for the best display
1.91:1aspect ratio to aim for, so nothing is cropped in the feed
600 x 315smallest size for a large image in link posts
8 MBmaximum file size

Source: Meta for Developers, sharing images guide

Give the image a stable URL and an alt text

Use a full URL that starts with https, such as https://www.example.com/images/open-graph-tags.jpg. A platform fetches the image from outside your page, so a path like /images/cover.jpg has no site attached to it when the platform reads it. Add og:image:width and og:image:height so the platform knows the size before it downloads the file. Add og:image:alt too. The protocol says that if the page specifies an og:image, it should specify og:image:alt.

The guide we checked lists no accepted file formats. We use JPG or PNG as a safe default. That is our choice, not a rule from Meta, and a crawler that reads both is the usual safe bet.

Keep the text away from the edges

Crops differ between apps, and a headline in the corner of your image can get cut off. Put the words you need to read in the middle third, leave a margin on every side, and check the picture at a small size on a phone. If the image only makes sense with the words, the words belong inside the image.

One image for every page

Many sites set one default picture for every page, usually the logo. It is quick to set up, and every shared link then looks the same. A shared logo tells the reader nothing about the article, so the card gets scrolled past. The fix is an image per page, which can be a designed picture or one generated from the page title.

One image for all pages or one per page?

One shared image
  • The same picture on every link
  • Readers cannot tell the posts apart
One image per page
  • Each card matches its article
  • Changing one page does not touch the others

Ways to add the tags, compared

There is no single right way to add Open Graph tags. The method depends on how your site is built, who edits the pages and how many pages you have. Below are the five methods we see in practice, from the simplest to the most automated. Each one has a principle, a best use, a main risk and an example. The comparison table at the end puts them side by side.

Method 1: Static HTML, written by hand

You write the tags directly in the head of each HTML file. This is the most transparent method. You can see every tag in the source, and nothing runs behind your back. It suits a small site, a landing page or a handful of documents that rarely change.

The risk is scale. Each new page needs its own tags, and someone will forget. A page without tags will not break your site, so nobody notices until a shared link looks wrong. Here is what a complete head looks like for one blog post:

<head>
  <meta property="og:title" content="Open Graph Tags: How to Set Them Up and Test Social Previews">
  <meta property="og:type" content="article">
  <meta property="og:url" content="https://www.example.com/blog/open-graph-tags">
  <meta property="og:description" content="Five steps to add the right tags, size the image and check the card before you share.">
  <meta property="og:image" content="https://www.example.com/images/open-graph-tags-1200x630.jpg">
  <meta property="og:image:width" content="1200">
  <meta property="og:image:height" content="630">
  <meta property="og:image:alt" content="Preview card of an article about Open Graph tags">
  <meta property="og:site_name" content="Example Shop">
  <meta property="og:locale" content="en_US">
</head>

Keep the content values plain, with no line breaks inside them. Use straight double quotes, and escape any quote that appears inside the text.

Method 2: A CMS plugin or theme field

Most content management systems offer a field for the title, description and image on each page, and many SEO plugins write the tags for you. This is the right choice for a WordPress site or any CMS where editors publish without touching code. The fields make the tags part of the publishing workflow, so a new page is more likely to have them.

The risk is duplication. A theme and a plugin can both print og:title, and then the page has two sets of tags that may disagree. Platforms do not guess which set you meant. Look at the source of a live page, count the og:title tags, and turn one source off if you see two.

Method 3: Framework metadata in Next.js or React

Modern frameworks have a metadata system. In Next.js, you export a metadata object from the page, and the framework renders the tags into the head on the server. The example below uses the App Router. Check your version of the framework, because the exact names change between releases.

export const metadata = {
  title: 'Open Graph Tags: How to Set Them Up and Test Social Previews',
  openGraph: {
    type: 'article',
    url: 'https://www.example.com/blog/open-graph-tags',
    images: [
      {
        url: 'https://www.example.com/images/open-graph-tags-1200x630.jpg',
        width: 1200,
        height: 630,
        alt: 'Preview card of an article about Open Graph tags',
      },
    ],
  },
};

The risk is client-side rendering. If the tags are added only after the browser runs your JavaScript, a crawler that does not run scripts sees an empty head. Test the framework output, not your local preview, with the source view of the deployed page. Our guides on Next.js SEO and React SEO cover the rendering questions in more depth.

Method 4: Server-side templates

If you run a custom application, the tags usually live in one shared layout or template. A product page, a category page and a blog post all inherit the same head, and you fill in the variables per page. This keeps the tags consistent and makes a template change reach every page at once.

The risk is the same at larger scale. A bug in the template removes the tags from thousands of pages in one deploy. Add a test that fetches a few URLs from each template and checks that the four required tags exist, and run it in your deploy pipeline.

Method 5: Generated images for each page

The most advanced method creates a picture for each page at the moment it is requested or built. The picture carries the page title, a short line and your brand colours, at 1200 x 630 pixels. Blogs with hundreds of articles and catalogues with thousands of products use it, because a designer cannot make that many images by hand.

The risks are real. Generation adds time and a point of failure. Fonts and special characters break easily, and a long title can overflow the frame. Cache the result, store it at a stable URL, and test a long title and an empty one before you roll it out.

The five methods side by side

MethodBest forMain riskEffort
Static HTMLSmall sites, a few landing pagesTags forgotten on new pagesLow per page, high at scale
CMS plugin or theme fieldWordPress and other CMS with editorsTwo plugins printing duplicate tagsLow
Framework metadataNext.js, React and similar appsTags added only in the browserMedium, once
Server-side templatesCustom sites with one layoutOne template bug hits every pageMedium, then low
Generated imagesBlogs and catalogues with many pagesBroken or slow generation, bad cropsHigh once, then low

Step by step: add and test the tags on one page

Start with a single page. Once one card works, repeat the process for the rest. The steps below take about thirty minutes for a page that already has a good image.

The six-step method

  1. Write the cardChoose the headline, the one-to-two-sentence description and the picture for this page.
  2. Prepare the imageMake it 1200 x 630 pixels, in JPG or PNG, under 8 MB, saved under a stable file name.
  3. Add the required tagsAdd og:title, og:type, og:image and og:url to the head, then og:image:width, og:image:height and og:image:alt.
  4. Check the served HTMLOpen the deployed page, view the source, and confirm the tags are in the HTML the server sends, not only after scripts run.
  5. Run the debuggerPaste the URL into Facebook's Sharing Debugger, read the warnings, and scrape the page again after each fix.
  6. Share a test linkPost the link in a private draft or a message to a colleague, and check that the card shows your title, your text and your picture.
Meta sharing guide for webmasters, with the Open Graph tags Facebook reads
Meta's guide explains which tags Facebook reads and what happens when they are missing.

Example

A blog post on example.com targets "open graph tags". The headline is "Open Graph Tags: How to Set Them Up and Test Social Previews", which is 60 characters. The picture is a 1200 x 630 JPG with the title in the centre and a clean background. The og:type is article. Once the tags are in the served HTML, the debugger shows the card, and the test message in a private draft shows the same headline and picture.

Common errors and how to fix them

Most card problems come from a short list of errors. Each one below describes what the error is, how to spot it, and how to fix it. Check for them in this order, because the first two are the most common.

Error 1: A relative image path

The tag reads content="/images/cover.jpg" instead of a full URL. Your browser shows the picture on your site without trouble, so the error hides well. What it is: the platform receives a path with no domain, and it cannot load the file from outside your page. How to spot it: the debugger shows no image or a broken one, while the picture looks fine on your site. How to fix it: write the full URL with https and the domain, and test it by opening the URL in a private browser window.

Error 2: Missing og:type on an article

The tag is absent, so the platform uses the default, which is website. What it is: your article is treated as a generic page. How to spot it: the debugger shows type website on a blog post. How to fix it: set og:type to article on every post, and to website on the home page and other general pages.

Error 3: A mismatch between og:url and the canonical

The og:url points to the http version, to a version with a tracking parameter, or to another page. What it is: shares of one page are counted against different addresses. How to spot it: the canonical tag in the source and the og:url differ, or the debugger shows a different URL from the one you pasted. How to fix it: make og:url equal to the canonical URL, using https and no tracking parameters.

Error 4: Tags injected only by JavaScript

The page builds its head in the browser, so the tags appear in the rendered page but not in the source the server sends. What it is: crawlers that do not run scripts see an empty head. How to spot it: view the source of the deployed page, not the inspector, and search for og:title. If it is missing, the tags are not in the server response. How to fix it: render the tags on the server, through the framework metadata system or the template, so they are present before any script runs.

Error 5: Two sets of tags from a theme and a plugin

A theme prints its own tags, and an SEO plugin prints a second set. What it is: the page has two og:title tags, and the platform may pick either. How to spot it: count the og:title tags in the source. How to fix it: keep one source for the social tags, usually the plugin, and disable the theme's output.

Error 6: An image that updates in the file but not in the card

You replace the picture at the same URL, but the card still shows the old one. What it is: Meta caches images by URL. How to spot it: the file on your server is new, but the debugger shows the old picture. How to fix it: give the new image a new file name, update og:image, and scrape again. The callout further down explains the cache in more detail.

Error 7: A missing or empty alt text

The og:image is set, but og:image:alt is absent or says "image". What it is: the card has no description for readers who use assistive technology, and an unhelpful alt text tells nobody anything. How to spot it: check the source for og:image:alt, and read the value out loud. How to fix it: write one short sentence that describes the picture and its message, in the same language as the page.

A head that breaks the card, then the fix

Before
  • Relative image path
  • Two og:title tags from theme and plugin
  • No og:type, no alt text
After
  • Full https image URL
  • One set of tags from one source
  • og:type article and a clear alt text

Testing, caching and keeping tags in sync

A card is only as good as your last test. Facebook's Sharing Debugger is the reference tool for Meta platforms. According to Meta's guide, it shows which meta tags the crawler scrapes, along with any errors or warnings, and it triggers a fresh scrape of your page. Use it after every change, and use it again after you fix an error, because the old scrape stays in place until the debugger refreshes it.

Sorank free Open Graph preview tool showing a link card
Sorank's free Open Graph preview tool shows the card before you publish.

For a quick check, you can paste a URL into our free Open Graph preview tool and see the card before you publish. Use it for every new article, then check the live page with the platform's own debugger, because a preview tool shows what it reads, not what each platform will display.

Tip

Open the Free Open Graph Preview Tool while you write the card. Change the headline and picture, then paste the final URL once it is live to confirm the tags.

Caching: why the old image stays

Warning

Meta caches images based on their URL. An image is not updated unless the URL changes. Replacing the file at the same address does nothing for the card. Rename the file, update og:image, and scrape again.

The same rule applies to the title and description. If the card still shows old text after you change it, the platform has a cached copy. Scrape the URL again in the debugger, and wait for the platform to refresh its copy before you assume the fix failed.

Keeping the tags in sync

Tags go stale when the article changes and nobody updates the card. Add the card to your publishing checklist: when the title changes, the og:title changes. When the image changes, the file name changes. When you move a page, the og:url changes, and you set a redirect from the old address.

For a site with many pages, sample a few URLs from each template every month. Pick the newest post, an old post, a category page and the home page. A sample of four pages finds most template bugs in a few minutes. For building the tag block for one page, our meta tags generator writes the head for you, and the SERP preview tool shows the search snippet next to it.

Twitter cards are meta tags whose names start with twitter:. X reads them to build the preview when someone posts your link. Set twitter:card to summary_large_image for a wide picture, then add twitter:site, twitter:title, twitter:description and twitter:image.

Open Graph tags do not count as Twitter tags. X may fall back to Open Graph when the Twitter tags are missing, but that fallback is not guaranteed, and the card may come out smaller than you planned. Write both sets. The Twitter tags take a few minutes to add.

The tags X reads

TagWhat it controlsPractical note
twitter:cardThe card type, summary or summary_large_imageUse summary_large_image for a wide picture
twitter:siteThe X account the card is attributed toWrite the handle with the @ sign
twitter:titleThe headline of the cardX cuts long titles, so keep it short
twitter:descriptionThe text under the headlinePut the main point at the start
twitter:imageThe picture, as a full URLUse https and the domain, never a path
twitter:image:altA text description of the pictureOne short sentence

Here is the block for the same blog post as the Method 1 example above:

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@yourbrand">
<meta name="twitter:title" content="Open Graph Tags: How to Set Them Up and Test Social Previews">
<meta name="twitter:description" content="Five steps to add the right tags, size the image and check the card before you share.">
<meta name="twitter:image" content="https://www.example.com/images/open-graph-tags-1200x630.jpg">
<meta name="twitter:image:alt" content="Preview card of an article about Open Graph tags">

Name the tags with name=, not property=

Open Graph tags use property=, and Twitter tags use name=. Mixing them up is a common mistake, and it is easy to miss because the tag looks right. Check the source of the live page and make sure every twitter: tag has name= in front of it.

Summary or large image

The summary card shows a small thumbnail next to the text. The summary_large_image card shows a wide picture that takes most of the post. Use the large card for articles and product pages with a designed image. Use the small card when your only picture is a logo or a square icon, because a logo blown up across a wide frame looks weak.

Keep the text and the image safe

Long titles and descriptions get cut, so the end of your sentence may disappear. Write a title that reads in one line, and a description that still makes sense if it is cut after the first line. Keep the words in the middle of the picture, because crops differ between apps. Use a full https URL in twitter:image, the same rule as og:image. If the picture only works with its words, the words belong inside the image.

Test the card, then refresh it

Post the link in a private draft or send it to a colleague, and check the card. X may keep an older copy of the page. After a fix, change the picture's file name, update twitter:image, and test again. Wait a while before you decide that the fix failed.

Tip

Write the handle in twitter:site exactly as it appears on your X profile, with the @ sign. Check the spelling against your profile before you publish the page.

Twitter cards are one part of your X presence. For the account side, read our guide on Twitter marketing. To see whether AI assistants cite X content, read our AI citation study on Twitter/X.

Where Open Graph fits next to meta tags and SEO

Open Graph sits next to the basic head tags that search engines and social platforms read. It does not replace them. The title tag, the meta description, the canonical tag and the structured data each have their own job. For the search side, read our guides on HTML tags for SEO and H1 tag SEO, and the glossary entry on meta tags.

Meta description or Open Graph description?

Meta description
  • Written for search result snippets
  • Does not set a picture for the card
Open Graph description
  • Written for the card a platform builds
  • Sits next to og:image and og:title

Open Graph has no direct effect on your ranking in Google. Its value is indirect. A good card can bring more visits from shares, and those visits can bring links and mentions over time. Measure the card by the clicks it brings, not by the ranking it might or might not change.

If you publish many pages, the work of keeping titles, descriptions and tags consistent is where a tool helps. Sorank's content optimization page describes how existing pages are reviewed and rewritten on autopilot.

Frequently asked questions

Do Open Graph tags help my Google ranking?

Not directly. Open Graph tags control how a link looks when someone shares it on social platforms or in messages. A clear card can bring more visits from those shares, and those visits can lead to links and mentions over time. Measure the card by the clicks it brings.

What size should my Open Graph image be?

Meta recommends at least 1200 x 630 pixels, with an aspect ratio as close as possible to 1.91:1, so the whole image shows in the feed without cropping. The file must not exceed 8 MB, and the URL must be a full https address.

Why does Facebook still show my old image after I replaced it?

Facebook caches images by URL, so replacing the file at the same address does not change the card. Give the new image a new file name, update og:image, then scrape the page again in the Sharing Debugger.

Get your content plan for 30 days for free

We analyse your competitors, your website and your AI visibility to create a tailored content plan for free.

Our free SEO tools

See all our free tools

Get your content plan for 30 days for free

We analyse your competitors, your website and your AI visibility to create a tailored content plan for free.

Man with dark hair and beard wearing a light brown shirt speaks in front of a microphone on a podcast or recording setup.Portrait of a man with short dark hair wearing a white shirt and dark jacket, looking directly at the camera with a neutral expression.Man with short dark hair, beard, and clear glasses wearing a black t-shirt with a white circular logo, standing in front of a stone wall.Celio fabianoSmiling young woman with long brown hair wearing a red top and necklace, outdoors in a tree-filled background.Profile photo of Xavier Breull, Sorank customer
Google
Solid yellow five-pointed star icon on transparent background.Solid yellow five-pointed star icon on transparent background.Solid yellow five-pointed star icon on transparent background.Solid yellow five-pointed star icon on transparent background.Solid yellow five-pointed star icon on transparent background.
5/5
+5,000
users

Testimonials from ambitious founders

0 to 10000 visitors in 5 months

Celio Fabianomonrobotlavevitre.frGoogleE-commerce

0 to 5000 visits in 8 months

Thibault BMsorank.comGoogleSoftware

0 to 1104 clicks in 4 months

Dominiqueflight-sensations-idf.comGoogleLeisure and aviation

0 to 163 clicks in 6 months

Coworking Pariscoworking-paris.frGoogleOffice broker

x92 clicks in 7 months

Guide Zanzibarguidezanzibar.comGoogleTravel