April 30, 2025 5 min read by Mykola Samila

I learned about Open Graph tags while optimizing a therapist's website for Facebook sharing. The site was a single page, but it was shared on social networks constantly — and the preview was showing a random image, a truncated URL as the title, and no description at all. A poor first impression for every share.

Open Graph tags are what give you control over that preview. Without them, Facebook, LinkedIn, and other platforms guess — and they usually guess wrong.

What are Open Graph tags

Open Graph is a protocol originally created by Facebook in 2010 that lets any web page define how it should appear when shared as a link. Today it is supported by Facebook, LinkedIn, Slack, WhatsApp, Discord, iMessage, and most other platforms that generate link previews.

The metadata is passed as the property attribute on a standard HTML <meta> tag, with values prefixed by og::

<meta property="og:title" content="Main title" />

The essential tags

These five cover the vast majority of use cases. Every page that gets shared should have all of them.

<meta property="og:title" content="Main title" />
<meta property="og:image" content="https://example.com/preview.jpg" />
<meta property="og:url" content="https://www.example.com/" />
<meta property="og:type" content="website" />
<meta property="og:description" content="Description with keywords" />

What each one does:

For article pages, add these two as well:

<meta property="og:site_name" content="Your Site Name" />
<meta property="article:published_time" content="2025-04-30" />
<meta property="article:author" content="Author Name" />

Image guidelines

The image is the single most important Open Graph tag. A few rules that save debugging time:

<meta property="og:image" content="https://example.com/preview.jpg" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:alt" content="Description of the image" />

Twitter Cards

Twitter (now X) has its own parallel system called Twitter Cards. The tags are similar but use a name attribute instead of property. Most platforms fall back to Open Graph if Twitter Card tags are missing, but setting both is the correct approach.

<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Main title" />
<meta name="twitter:description" content="Description" />
<meta name="twitter:image" content="https://example.com/preview.jpg" />

The twitter:card value controls the layout. summary_large_image shows a full-width image above the title — the most visually prominent option and the one worth using for most pages.

Where to place them

Place all Open Graph tags inside the <head> element, as early as possible — ideally before any stylesheets or scripts. Social media crawlers are not full browsers; they stop parsing after a certain point, and tags buried at the bottom of a large <head> may not be read.

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <!-- Open Graph — place near the top -->
  <meta property="og:title" content="Main title" />
  <meta property="og:description" content="Description" />
  <meta property="og:image" content="https://example.com/preview.jpg" />
  <meta property="og:url" content="https://example.com/" />
  <meta property="og:type" content="website" />

  <!-- Twitter Cards -->
  <meta name="twitter:card" content="summary_large_image" />
  <meta name="twitter:title" content="Main title" />
  <meta name="twitter:description" content="Description" />
  <meta name="twitter:image" content="https://example.com/preview.jpg" />

  <link rel="stylesheet" href="styles.css" />
</head>

Debugging and preview tools

After adding your tags, platforms cache the old preview for a while. You need to force them to re-scrape. These tools do that and show you exactly what the preview will look like:

For the full list of available Open Graph properties — including music, video, book, and profile types — the official reference is at ogp.me.

Invest the time during development to set these up correctly. Every share of your page is a small advertisement — Open Graph tags determine whether that advertisement looks professional or broken.

Need help with SEO or social sharing on your site?

Get in touch

← All articles  ·  Portfolio