TechCompare LogoTechCompare

How to generate Open Graph tags: a practical guide for any website

OG tags are the lowest-effort, highest-impact SEO improvement you can make. Five minutes of work makes every link shared from your site look professional instead of broken. Do it now, validate it, and never think about it again.

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.

By TechCompare · Updated

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'. 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

Six or eight meta tags in the head cover most cases: og:title, og:description, og:image, og:url, og:type, plus twitter:card on summary_large_image. The integration path depends on the stack. Plain HTML in the head, react-helmet-async or React Router Helmet for React, the Metadata API or generateMetadata in Next.js, and Yoast SEO or Rank Math in WordPress. Host the 1200x630 JPEG on the same domain to sidestep cross-origin issues.

More OG scenarios

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.