Skip to main content

Open Graph & Social Media Cards 🃏

Mentor's Note: Social cards are your website's first impression on social media! When someone shares your link, the card that appears is like a mini-billboard for your content. Get it right, and people will click through. Get it wrong, and you're invisible. 🎯


🧠 What Are Social Cards?

Social cards (or rich previews) are the link previews generated by social platforms — Facebook, Twitter/X, LinkedIn, WhatsApp, Slack, Telegram, Discord — when a user shares a URL. Instead of showing a bare URL, they display a formatted card with a title, description, image, and site name.

The Social Card Flow:

Without Open Graph tags, platforms fall back to guessing — often picking the wrong image, truncating descriptions, or showing a generic card. You lose control of your brand's appearance.


📖 The Open Graph Protocol

The Open Graph (OG) Protocol was introduced by Facebook in 2010 to standardize how web pages are represented on social platforms. It allows any page to become a rich object in a social graph.

Essential OG Meta Tags:

PropertyPurposeExample
og:titleTitle of the page"Complete HTML Tutorial"
og:descriptionPage description (2–4 sentences)"Learn HTML from scratch with hands-on examples and real projects."
og:imagePreview image URL (absolute URL)"https://example.com/og-image.jpg"
og:urlCanonical URL of the page"https://example.com/html-tutorial"
og:typeContent type"website", "article", "video.movie"
og:site_nameName of your website"VD Computer Tuition"
og:localeLanguage and region"en_US", "hi_IN"

Image Best Practices:

  • Size: 1200×630 px (1.91:1 ratio) — the standard for most platforms
  • Format: PNG or JPG
  • Max Size: Under 5 MB
  • Text: Minimize text on the image; many platforms crop or overlay on mobile
  • Contrast: Ensure the image is readable in both light and dark mode previews

🐦 Twitter Cards

Twitter originally had its own card system (Twitter Cards), but now primarily uses Open Graph tags (with Twitter-specific fallbacks). Always include both for maximum compatibility.

Twitter Card Meta Tags:

Meta TagPurpose
twitter:cardCard type (summary, summary_large_image, player, app)
twitter:site@username of the website/author
twitter:titleCard title (falls back to og:title if omitted)
twitter:descriptionCard description (falls back to og:description)
twitter:imageCard image (falls back to og:image)

Card Type Comparison:

Card TypeWhen to Use
summaryBlog posts, articles, text-heavy pages
summary_large_imageVisual content, portfolios, landing pages
playerVideo/audio embeds (podcasts, YouTube, etc.)
appMobile app download pages (iOS/Android)

🔧 Validation & Testing Tools

Always test your social cards before publishing:

ToolURLPurpose
Facebook Sharing Debuggerhttps://developers.facebook.com/tools/debug/Debug OG tags, refresh Facebook's cache
Twitter Card Validatorhttps://cards-dev.twitter.com/validatorValidate Twitter Card rendering
LinkedIn Post Inspectorhttps://www.linkedin.com/post-inspector/Check how LinkedIn renders your link
Slack UnfurlsPaste URL in any Slack channelSlack fetches fresh metadata on paste
WhatsApp PreviewPaste URL in a chatMobile-only preview tester
OpenGraph.xyzhttps://opengraph.xyz/Preview OG tags from any URL
Metatags.iohttps://metatags.io/Live preview + editable OG tag simulator

⚠️ Caching: Social platforms aggressively cache OG data. After updating your tags, use the debugger tools above to force a cache refresh — otherwise old previews may persist for hours or days.


💻 Complete Example

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Tutorial — Learn Web Development | VD Computer Tuition</title>
<meta name="description" content="Master HTML from scratch with hands-on examples, real projects, and expert guidance. Perfect for beginners and board exam preparation." />

<!-- Open Graph / Facebook / LinkedIn / WhatsApp / Slack -->
<meta property="og:type" content="website" />
<meta property="og:url" content="https://vdcomp.tech/programming/html/" />
<meta property="og:title" content="HTML Tutorial — Learn Web Development" />
<meta property="og:description" content="Master HTML from scratch with hands-on examples, real projects, and expert guidance. Perfect for beginners and board exam preparation." />
<meta property="og:image" content="https://vdcomp.tech/assets/images/og-html-tutorial.jpg" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:alt" content="HTML Tutorial preview showing code editor and browser output" />
<meta property="og:site_name" content="VD Computer Tuition" />
<meta property="og:locale" content="en_US" />

<!-- Twitter Card -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@vdcomp" />
<meta name="twitter:title" content="HTML Tutorial — Learn Web Development" />
<meta name="twitter:description" content="Master HTML from scratch with hands-on examples, real projects, and expert guidance." />
<meta name="twitter:image" content="https://vdcomp.tech/assets/images/og-html-tutorial.jpg" />
<meta name="twitter:image:alt" content="HTML Tutorial preview showing code editor and browser output" />

<!-- Additional Structured Data (optional, boosts SEO) -->
<link rel="canonical" href="https://vdcomp.tech/programming/html/" />
</head>
<body>
<!-- Page content -->
</body>
</html>

❌ Common Mistakes

MistakeWhy It's WrongFix
Relative image URLsPlatforms fetch from their server, not yours — relative paths breakAlways use absolute URLs (https://...)
Missing og:imagePlatforms show no image or pick a random oneAlways provide at least one OG image
Oversized imagesSlow load times; platforms may rejectKeep under 5 MB, use 1200×630 px
Text-heavy OG imagesText gets cropped on mobile viewportsUse minimal text, rely on og:title and og:description
Missing twitter:cardTwitter shows a plain link instead of a rich cardAlways set twitter:card even if it falls back to OG
Ignoring cacheUpdating tags but old preview still showsUse debugger tools to refresh cache
Wrong og:typePlatform may not render as expectedUse "website" for general pages, "article" for blog posts
No canonical URLDuplicate content confusion for both SEO and socialAlways add <link rel="canonical">
HTTPS mismatchMixed content warnings; image may not loadServe OG images over HTTPS, same as the page
Forgetting og:image:altAccessibility issue; platforms use it for screen readersDescribe the image content briefly

🚀 Next Steps

  1. Audit your pages — Use Metatags.io or OpenGraph.xyz to check current pages
  2. Generate OG images — Create a template (1200×630 px) in Canva or Figma
  3. Add tags to your template — Place OG tags in your site's <head> partial/layout
  4. Test every platform — Use the debugger tools listed above for Facebook, Twitter, LinkedIn
  5. Automate — If using a CMS or static site generator, set up automatic OG image generation (e.g., Vercel OG, Satori)
  6. Monitor — Periodically re-test pages after site updates