# How to add Open Graph meta tags for link previews

> Add title, description, og:image and X card tags so shared links show a proper preview, pick the right image size, and test the result before you post.

- URL: https://www.tooljig.com/blog/how-to-add-open-graph-meta-tags
- Category: Developer
- Published: 2026-11-23

When someone pastes your link into a chat app or a social network, the preview card they see is built from a handful of meta tags in your page's `<head>`. Without them, platforms guess: they pick a random image, cut the title short, or show a bare URL. With them, you decide the title, description and image people see before they click. This guide shows which tags to add, how to size the image, and how to check the preview.

> Tool: [Meta Tag Generator](https://www.tooljig.com/meta-tag-generator): Generate SEO, Open Graph and X (Twitter) card meta tags with character counts, URL checks and search and social previews. Copy ready-to-paste HTML.

## Step by step

1. Open the [meta tag generator](https://www.tooljig.com/meta-tag-generator) and enter the **Page title**, **Meta description** and **Canonical URL**. The character counts help you keep the title to about 60 characters and the description to about 155.
2. Leave **Allow indexing** and **Follow links** on for a normal public page. Add a **Theme color** if you want mobile browsers to tint their interface.
3. Fill in the Open Graph fields. **og:title**, **og:description** and **og:url** can stay empty; they reuse the page title, description and canonical URL.
4. Enter the **og:image** as an absolute `https://` URL, choose an **og:type** (usually `website`, or `article` for a blog post), and add **og:site_name** and **og:locale** such as `en_US`.
5. Pick a **twitter:card** type: `summary_large_image` for a wide image above the title, or `summary` for a small square thumbnail.
6. Check the approximate search result and social card previews, fix anything the tool flags (such as a relative URL), and copy the HTML into your page's `<head>`.

## The tags that matter

The Open Graph protocol, originally published by Facebook and documented at ogp.me, defines four basic properties every page should have: `og:title`, `og:type`, `og:image` and `og:url`. Most platforms that show link previews, including Facebook, LinkedIn, Slack, Discord, WhatsApp and iMessage, read them. A complete head for a blog post looks like this:

```html
<title>How to repot a fiddle-leaf fig</title>
<meta name="description" content="When to repot, which soil to use and how to avoid shocking the roots, with photos of each step.">
<link rel="canonical" href="https://example.com/blog/repot-fiddle-leaf-fig">

<meta property="og:title" content="How to repot a fiddle-leaf fig">
<meta property="og:description" content="When to repot, which soil to use and how to avoid shocking the roots, with photos of each step.">
<meta property="og:url" content="https://example.com/blog/repot-fiddle-leaf-fig">
<meta property="og:image" content="https://example.com/images/repot-share.png">
<meta property="og:type" content="article">
<meta property="og:site_name" content="Example Gardens">
<meta property="og:locale" content="en_US">

<meta name="twitter:card" content="summary_large_image">
```

Note the attributes: Open Graph tags use `property=`, while `description` and the `twitter:` tags use `name=`.

### What each tag does

| Tag | Purpose |
| --- | --- |
| `og:title` | The headline on the card. Can differ from `<title>`, for example without the site name suffix |
| `og:description` | One or two sentences under the title. Many platforms truncate after a line or two |
| `og:image` | The preview image. Must be an absolute URL |
| `og:url` | The canonical address of the page, so shares of different URL variants are grouped together |
| `og:type` | `website` for most pages, `article` for posts; other types exist for products, profiles, video and music |
| `og:site_name` | Your site or brand name, shown by some platforms above or below the title |
| `og:locale` | The content language in `language_TERRITORY` form, such as `en_GB` |
| `twitter:card` | The card layout on X: `summary` or `summary_large_image` |

X (formerly Twitter) reads `og:title`, `og:description` and `og:image` when its own `twitter:title`, `twitter:description` and `twitter:image` are missing, so you only need `twitter:card` unless you want different text on X. That is why the generator writes only that one.

## Choosing and sizing the preview image

A size of **1200 × 630 pixels**, an aspect ratio of about 1.91:1, is the widely recommended size for large link previews. It displays well on Facebook and LinkedIn, and `summary_large_image` cards on X crop it only slightly. Practical guidance:

- **Keep important content in the center.** Platforms crop differently, and some show a square thumbnail in compact layouts. Text near the edges may be cut off.
- **Use large, short text if any.** The card is often shown at a fraction of its full size on phones.
- **Use PNG or JPEG.** Support for WebP and SVG in previews is inconsistent across platforms; SVG in particular is widely unsupported for `og:image`.
- **Keep the file small.** Some crawlers give up on slow or very large images. A few hundred kilobytes is plenty for 1200 × 630; see [how to reduce image size for a website](https://www.tooljig.com/blog/how-to-reduce-image-size-for-a-website).
- **Use an absolute `https://` URL** that is publicly reachable, not behind a login, and not blocked by `robots.txt`.

You can add `og:image:width`, `og:image:height` and `og:image:alt` by hand below the generated tags. Width and height help some platforms render the card on the first share without downloading the image first, and alt text describes the image to screen reader users on platforms that support it.

## Clean URLs for canonical and og:url

The URL in your canonical link and `og:url` appears on cards and is what people copy. Short, readable slugs make it easier to trust. The [slug generator](https://www.tooljig.com/slug-generator) turns a title such as "How to Repot a Fiddle-Leaf Fig" into `how-to-repot-a-fiddle-leaf-fig`, with an option to drop stop words. Keep `og:url` identical to the canonical URL, including the protocol, `www` or not, and any trailing slash. If you are dealing with query strings or tracking parameters, the [URL parser](https://www.tooljig.com/url-parser) shows each part of an address so you can strip what does not belong.

Finish the head with a favicon, which some platforms show next to the site name; the [favicon generator](https://www.tooljig.com/favicon-generator) makes the files you need.

## Testing the preview

The generator's preview is an approximation built from your values. Before you share a link widely, check it in the platforms that matter to you:

1. Deploy the page so it is publicly reachable. Crawlers cannot see `localhost` or pages behind authentication.
2. Use the official tools where they exist: Facebook's Sharing Debugger and LinkedIn's Post Inspector both fetch your page, show the tags they found and the resulting card.
3. For chat apps, paste the link into a private conversation with yourself.

> **Note:** Platforms cache previews, sometimes for days. If you change an image or title after a link has been shared, the old card can keep appearing. The Facebook and LinkedIn tools let you request a fresh scrape. Giving a changed image a new file name also helps, because many platforms cache images by URL.

Common reasons a preview does not appear: the tags are added by JavaScript after the page loads (most crawlers do not run scripts, so tags must be in the server-rendered HTML), the image URL is relative or returns an error, or the server blocks unfamiliar user agents.

## FAQ

### What size should an og:image be?

1200 × 630 pixels, about 1.91:1, is the widely recommended size for large previews. Keep key content near the center and use an absolute `https://` URL to a PNG or JPEG.

### Do I need separate Twitter tags?

Usually not. X falls back to the Open Graph title, description and image, so `twitter:card` is enough. Add `twitter:title` or `twitter:image` only if you want X to show something different.

### Why does my link still show the old preview?

The platform has cached it. Use the platform's debugging tool to request a new scrape, and consider renaming the image file so its URL changes.
