Open Graph, Twitter Cards & JSON-LD Structured Data

Open Graph, Twitter Cards & JSON-LD Structured Data in HTML: When links to your application are shared on social platforms (Slack, Twitter/X, LinkedIn,…

When links to your application are shared on social platforms (Slack, Twitter/X, LinkedIn, Discord, iMessage, Facebook), platform scrapers parse the page's metadata to render interactive visual link previews (Social Cards).


The Open Graph Protocol (OG)

Open Graph metadata is declared using <meta property="og:...">:

<!-- Canonical URL: Prevents duplicate content penalties -->
<link rel="canonical" href="https://www.codeacademix.dev/python-learning">

<!-- Primary Open Graph Tags -->
<meta property="og:site_name" content="CodeAcademix">
<meta property="og:title" content="Learn Python Online: In-Browser Practice | CodeAcademix">
<meta property="og:description" content="Master Python 3 with hands-on exercises and real-time execution in our free in-browser IDE.">
<meta property="og:url" content="https://www.codeacademix.dev/python-learning">
<meta property="og:type" content="website">

<!-- Optimal OG Image Specifications: 1200x630 pixels (1.91:1 ratio) -->
<meta property="og:image" content="https://www.codeacademix.dev/og/python-course.jpg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Preview of the Python programming course on CodeAcademix">

Twitter Cards (X Cards)

Twitter uses dedicated metadata to display large card previews:

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@codeacademix">
<meta name="twitter:creator" content="@codeacademix">
<meta name="twitter:title" content="Learn Python Online | CodeAcademix">
<meta name="twitter:description" content="Master Python 3 with real-time in-browser code execution.">
<meta name="twitter:image" content="https://www.codeacademix.dev/og/python-course.jpg">

JSON-LD Structured Data (Schema.org)

Google search algorithms use JSON-LD (JavaScript Object Notation for Linked Data) embedded within a <script type="application/ld+json"> block to render Rich Snippets (star ratings, course breadcrumbs, FAQ dropdowns) in search results:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Course",
  "name": "Python Fundamentals Masterclass",
  "description": "Learn Python 3 syntax, data structures, and algorithms through interactive coding.",
  "provider": {
    "@type": "Organization",
    "name": "CodeAcademix",
    "sameAs": "https://www.codeacademix.dev"
  },
  "educationalLevel": "Beginner",
  "isAccessibleForFree": true,
  "offers": {
    "@type": "Offer",
    "price": "0",
    "priceCurrency": "USD",
    "category": "Free"
  }
}
</script>

Exercises

  1. Author a valid JSON-LD schema block for an educational Course page and validate it using the Google Rich Results Test.
  2. Build an Open Graph card image specification with exact 1200x630 dimensions.
  3. Explain why the canonical link (<link rel="canonical">) prevents SEO ranking dilution between http://, https://, and query-string URLs.