Speed and SEO
Open Graph tag generator for X cards and WordPress
Use this Open Graph tag generator to write the og: and X (Twitter) card tags for a page and see how its link will look on Facebook, X, LinkedIn, Slack, Discord, WhatsApp, Messages and in Google as you type. Copy them as HTML for any website, as a snippet for a WordPress child theme, or download a small WordPress plugin. Everything happens in your browser; nothing you type is sent to this site.
- Live previews
- HTML, snippet or plugin
- Runs in your browser
Free, no sign-up. Nothing you type is sent to this site.
This tool needs JavaScript. Turn JavaScript on and reload the page.
Social share preview
Check a page
See how a link to your page will look on Facebook, X, LinkedIn, Slack, Discord, WhatsApp, Messages and in Google, with every Open Graph and X card tag read, the sharing image measured and each problem explained with a fix.
What this check looks at
- The Open Graph tags (og:title, og:description, og:image with its size, alt text and secure address, og:url, og:type, og:site_name) and the X card tags (twitter:card, title, description, image, site).
- The page’s own title, meta description, canonical address, site icon, Apple touch icon, theme colour and language, which the platforms fall back to.
- The sharing image itself, downloaded once: its real pixel size, file size and format, whether it loads over HTTPS, and each platform’s published size, shape and file size rules.
- Where the tags sit in the HTML: Facebook reads the first 1 MB, WhatsApp needs the head in the first 300 KB, Messages reads at most 1 MB.
The page is fetched once, as the platforms’ link preview robots do: redirects are followed and no JavaScript is run, so tags added by a script are not seen, by this check or by the platforms. The mock-ups follow each platform’s published rules but are not pixel-perfect copies; apps change their designs, and shortened text is cut where it would roughly be cut.
The rules come from: Meta for Developers (opens in a new tab), X’s former card documentation (archived; X no longer publishes current numbers, so its figures are shown as notes only) (opens in a new tab), LinkedIn Help (opens in a new tab), Slack (opens in a new tab), Discord’s developer docs (opens in a new tab), WhatsApp’s developer docs (opens in a new tab) and Apple’s TN3156 (opens in a new tab).
Generate Open Graph and X card tags
Fill in what you want people to see when your page is shared, watch the previews change, then copy the code for your site: plain HTML for any website, or a snippet or a ready-made plugin for WordPress. Only the fields you fill in are written. Everything happens in your browser and nothing you type is sent to this site. To measure the image, your browser loads it from the address you type, so the site that hosts it sees that request.
Live previews
Approximate mock-ups built from each platform’s published rules, as in the checker. The image loads from the address you entered.
Your code
1. Any website: HTML for the <head>
- Open the page’s HTML (or your site builder’s “custom head code” setting).
- Find the <head> section near the top, between <head> and </head>.
- Remove any og: or twitter: tags already there, paste the code just before </head> and publish.
- Check the page with the “Check a page” tab, then refresh each platform’s copy (see below).
2. WordPress: child theme functions.php
- Use a child theme: changes to the parent theme’s files are lost when it updates.
- Open the child theme’s functions.php over SFTP or in your host’s file manager, or under Appearance › Theme File Editor (Tools › Theme File Editor on block themes). The editor saves straight to the live site and can be turned off by your host; a mistake in functions.php can stop the site loading, so keep a copy and prefer SFTP.
- Paste the code once, at the end of the file, below the opening <?php line, and save. If the file ends with ?>, paste above that line, or the code is shown as text on every page. When you change the tags, replace the code from this generator rather than adding a second copy, or every tag is printed twice.
- The code prints the tags on the page you chose only, sets that page’s <title> through WordPress (themes that support title-tag) and replaces WordPress’s own canonical link when you entered one. Every value is passed through esc_attr(), esc_url() or esc_html().
3. WordPress: download as a plugin
The same code as a small plugin, so it survives theme changes: the plugin ZIP.
- In WordPress, go to Plugins › Add New Plugin (Add New in older versions) and press Upload Plugin.
- Choose the ZIP you downloaded, press Install Now, then Activate.
- To change the tags later, make a new ZIP here, deactivate and delete the old plugin, and upload the new one.
Fixed the tags but the old preview still shows?
Each platform keeps its own copy of a page’s preview, so a change shows only after it fetches the page again.
- Facebook: paste the address into Meta’s Sharing Debugger (opens in a new tab) and press Scrape Again. Facebook keeps images by address, so a changed picture needs a new file name.
- LinkedIn: the Post Inspector (opens in a new tab) shows what LinkedIn reads from the page and when it last read it. You need to be signed in to LinkedIn.
- X: X’s Card Validator no longer shows previews (opens in a new tab), since August 2022. Paste the link into a new post instead: the card appears without posting. X’s former developer documentation (opens in a new tab) said it reads a page’s card tags again roughly every seven days; X no longer publishes this.
- Discord: previews are kept for about 30 minutes. To see a change at once, share the address with a new query string, such as ?v=2, or open Discord’s Embed Debugger (opens in a new tab).
- Slack: Slack keeps a preview for around 30 minutes, then fetches the page again.
- WhatsApp and Messages: there is no public tool. Paste the link into a message without sending it: WhatsApp shows the preview above the message box within about 10 seconds.
- WordPress: clear your caching plugin’s or host’s page cache first, or the platforms may fetch the old page.
What you can do
-
Fill in og:, article:, fb:app_id and twitter: tags with help for each
-
Watch eight link previews update as you type
-
See where X, Discord and WhatsApp cut your title and description
-
Copy HTML with every value escaped, for any website
-
Copy a WordPress functions.php snippet or download a plugin
-
Fill the form from a page you checked, to fix what was found
How to make Open Graph tags
-
Fill in the fields
Enter the title, description, page address and image address. The image size is measured for you when your browser loads it. Leave out anything you do not need: only filled fields are written.
-
Check the previews
The previews show the card on each platform, and the counters say where X, Discord and WhatsApp would cut your text.
-
Add the code to your site
Copy the HTML into the page’s <head>, or on WordPress paste the snippet into a child theme’s functions.php or upload the plugin. Then check the page and refresh each platform’s copy.
Adding the tags to your site
The generator writes the same tags three ways. For any website, copy the HTML and paste it inside the page’s <head>. On WordPress, copy the functions.php snippet into a child theme, or download the plugin and upload it under Plugins › Add New Plugin › Upload Plugin. The WordPress code prints the tags on the page you choose only, sets that page’s title through WordPress, replaces WordPress’s own canonical link when you enter one, and escapes every value.
Image guidance
Use a 1200 × 630 px JPEG, PNG or WebP under 600 KB. That is Meta’s recommended size and the 1.91:1 shape Meta and LinkedIn suggest, it meets LinkedIn’s 1200 × 627 px minimum, and it stays under LinkedIn’s 5 MB and WhatsApp’s 600 KB. X no longer publishes image sizes for cards. Keep the important part in the middle, as some apps crop the edges.
After adding the tags
Check the page with the Check a page tab, then make each platform fetch it again: Meta’s Sharing Debugger for Facebook, LinkedIn’s Post Inspector, and a new query string such as ?v=2 for Discord. X’s Card Validator no longer shows previews; paste the link into a new post instead.
Frequently asked questions
Which tags do I need for a good link preview?
og:title, og:description, og:image and og:url cover Facebook, LinkedIn, WhatsApp, Slack, Discord and Messages; LinkedIn lists exactly these four as required. Add og:type, og:image:width, og:image:height and og:image:alt, and twitter:card so X knows which card to show. X takes the title, description and image from the Open Graph tags when there are no twitter: versions.
Why does the generator use property= for og: tags and name= for twitter: tags?
The Open Graph protocol and Meta’s examples write Open Graph tags as <meta property="og:…">, and X’s card markup writes its tags as <meta name="twitter:…">. The generator follows each one’s own documentation.
Do I need fb:app_id?
Only for Facebook Insights: Meta says you must add the app ID to your page to use Insights. It does not change how the link looks, and leaving it out does not stop sharing.
I use Yoast SEO or Rank Math. Should I paste this code?
No. Yoast SEO, Rank Math, SEOPress and All in One SEO already print these tags; set the values in the plugin’s social settings for the post instead. With a second set of tags, each platform picks one of the two. Use the generator’s code only when nothing on your site prints Open Graph tags, which the Check a page tab shows.
Is the WordPress code safe to paste?
Every value is written as a PHP string and printed through WordPress’s own escaping functions, esc_attr(), esc_url() and esc_html(), so quotes or code in what you typed cannot break the page. The code runs only on the page you choose. Paste it into a child theme’s functions.php, or use the plugin download, so a theme update does not remove it.
Is what I type sent anywhere?
Nothing is sent to this site: the generator runs in your browser. To measure your image and show it in the previews, your browser loads it from the address you enter, so the server that hosts it sees that request, as with any image.
Related tools
-
SEO report
New (added recently)Check one page’s SEO basics and PageSpeed, then download the report as a PDF.
-
Generate JSON-LD schema markup for businesses, articles, products, breadcrumbs and FAQs.
-
Favicon generator
New (added recently)Make favicon.ico, Apple and Android icons and a web app manifest from your logo or a letter, in your browser.
-
Website speed test
New (added recently)Test a page’s speed on mobile and desktop with Google PageSpeed Insights, plus accessibility, best practices and SEO scores, a waterfall and WordPress fixes.