Open Graph Tags: What Every Web Developer Needs to Know

3 42
calendar_today agoschedule3 min read

When someone shares your URL on Twitter, LinkedIn, Slack, or iMessage, the preview card that appears is controlled by Open Graph meta tags. Without them, platforms guess — often badly. This guide covers everything you need to know.

The Minimum Viable Set

Add these to every page's :

``html

`

Plus Twitter Cards (needed separately):

<code>html <meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:title" content="Page Title" /> <meta name="twitter:description" content="One sentence description." /> <meta name="twitter:image" content="https://example.com/og-image.jpg" /> </code>

The og:image Rules

This is the tag that matters most for click-through rate. Get it wrong and you get a broken preview.

  • Size: 1200×630 pixels (the safe size that works across all platforms)
  • Format: JPG or PNG — avoid WebP (inconsistent support)
  • URL: must be absolute — https://example.com/img.jpg, not /img.jpg
  • File size: under 1 MB

If you leave it out, platforms either show nothing or grab a random image from the page (usually something small and irrelevant).

og:type and Article Tags

For blog posts, use article type and add the article metadata:

<code>html <meta property="og:type" content="article" /> <meta property="article:author" content="https://yoursite.com/about" /> <meta property="article:published_time" content="2024-05-31T10:00:00Z" /> <meta property="article:section" content="Technology" /> </code>

For everything else (tools, homepages, landing pages): use website.

Common Mistakes

1. Forgetting og:image — the biggest missed opportunity. Links without images get far fewer clicks.

2. Relative URLs for images — background: /images/og.jpg doesn't work. Must be absolute.

3. Titles over 70 characters — platforms truncate longer titles, sometimes mid-word.

4. Same image on every page — fine for the homepage, but article pages should have unique images.

5. Not refreshing the cache — social platforms cache metadata for hours or days. After changing OG tags, use Twitter's Card Validator or Facebook's Sharing Debugger to force a refresh.

Platform Compatibility

| Platform | Reads | Card Type |

|----------|-------|-----------|

| Facebook | og: | Large image |

| Twitter/X | twitter: (falls back to og:) | summary_large_image |

| LinkedIn | og: | Large image |

| Slack | og: | Inline preview |

| Discord | og: | Embeds og:video too |

| iMessage | og: | Small preview |

| WhatsApp | og: | Small preview |

Validate Before You Ship

Never deploy OG tag changes without validating:

  • Twitter Card Validator: cards-dev.twitter.com/validator
  • Facebook Sharing Debugger: developers.facebook.com/tools/debug/
  • LinkedIn Post Inspector: www.linkedin.com/post-inspector/`

These tools show you exactly how your link will look and let you force a cache refresh.

For generating and previewing your meta tags without any coding, SnappyTools has free developer tools for HTML encoding, minification, and more — useful for cleaning up any special characters in your OG tag content with the HTML Entity Encoder.

1.6k Points45 Badges3 42
66Posts
0Comments
SnappyTools builds free, fast, browser-based tools for developers, writers, and designers. No signup required, no data uploaded, no nonsense — just clean tools that work instantly in your browser. We cover the full developer workflow: JSON formatting, Base64 encoding, URL encoding, HTML entity encoding, CSS and HTML minification, Markdown conversion, UUID generation, and more. Plus writing tools like readability checkers, word counters, and keyword density analysis. New tools added every week b...
Build your own developer journey
Track progress. Share learning. Stay consistent.
🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

I’m a Senior Dev and I’ve Forgotten How to Think Without a Prompt

Karol Modelskiverified - Mar 19

TypeScript Complexity Has Finally Reached the Point of Total Absurdity

Karol Modelskiverified - Apr 23

Sovereign Intelligence: The Complete 25,000 Word Blueprint (Download)

Pocket Portfolio - Apr 1

Dog CT Scan Cost: What Pet Parents Need to Know

Huifer - Feb 6

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

5 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!