How to generate Open Graph tags for any website

By TechCompare · Updated · How we check

Adding OG tags takes about five minutes and gives every shared link a title, description, and image instead of a platform's guess. Add them, then validate with the Facebook Sharing Debugger.

Adding Open Graph tags to a website takes about 5 minutes. You add 6-8 <meta> tags to the <head> of each page. The tags tell social platforms what title, description, and image to use when someone shares the URL. Without them, platforms guess, and the guess is usually wrong.

Platform or focus
Best Practices
OG tag strategy and tooling
Topic detail
OG tag generator
tag-generator

How this is calculated

The minimum viable OG tag set: og:title, og:description, og:image, og:url, og:type (usually 'website' for the homepage, 'article' for content), plus twitter:card set to 'summary_large_image'.

How you add them depends on your stack:

  • In a plain HTML site, add <meta property='og:title' content='...'> to the <head>.
  • In React, use react-helmet-async or the native Helmet component in React Router.
  • In Next.js, use the Metadata API or generateMetadata.
  • In WordPress, Yoast SEO and Rank Math both add OG tags automatically.

For the og:image, host a 1200x630 JPEG at a stable URL, preferably on the same domain as the page to avoid cross-origin issues. After adding tags, validate with the Facebook Sharing Debugger.

Verdict

Add six to eight meta tags to the head: og:title, og:description, og:image, og:url, og:type, plus twitter:card on summary_large_image. Plain HTML takes them directly in the head, React uses react-helmet-async or React Router Helmet, Next.js has the Metadata API or generateMetadata, and WordPress gets them from Yoast SEO or Rank Math. Host the 1200x630 JPEG on the same domain to sidestep cross-origin issues.

More OG scenarios

OG image dimensions
The de facto standard Open Graph image size is 1200x630 pixels, a 1.91:1 aspect ratio.
View details
Twitter Card types
Twitter Cards control how your URL appears when shared on X (formerly Twitter).
View details
Facebook vs Twitter tags
Open Graph (og:) tags are the standard, originated by Facebook and now supported by LinkedIn, Discord, Slack, WhatsApp, and most other platforms.
View details

Frequently asked questions

What are the minimum Open Graph tags every page needs?
Five: og:title, og:description, og:image, og:url, and og:type ('website' for a homepage, 'article' for content pages). Add twitter:card set to summary_large_image on top and you have the set that covers Facebook, LinkedIn, Twitter, and every chat app that reads OG. That's six meta tags for previews that stop looking broken.
How do I add OG tags in React or Next.js?
In React, use react-helmet-async or React Router's Helmet to inject the meta tags into the head per route. In Next.js, the App Router's Metadata API (or generateMetadata for dynamic routes) does it natively in the layout or page file. Both are build-time or server-side, which matters because social crawlers don't reliably run client-side JavaScript.
Do I need an SEO plugin for OG tags in WordPress?
Practically yes. Yoast SEO and Rank Math both generate OG tags automatically from your post title, excerpt, and featured image, and let you override per post. Hand-editing a theme's head section works but breaks on every theme update, so the plugin route is what survives contact with a real WordPress install.