Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 6.3 — Social Sharing Cards
HTML · Example 2 of 2

How X falls back to Open Graph

twitter: tags win, then og: tags, then the plain title and description. The ?? operator picks the first value that isn't missing.

Open Graph and Twitter card meta tags tell WhatsApp, LinkedIn, Facebook, X, Slack and Discord what title, description and image to show when someone shares your link.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write the full set of social tags for a blog post How I learned to code at 40 on https://ravi.example/blog/code-at-40, with an image https://ravi.example/og/code-at-40.png and the large X card.

02

Write a function checkCard() that logs the names of any of the four required OG tags that are missing from the page, or All required OG tags present.

Explain it without notes

01

How does a chat app build a link preview, and why don't tags added by JavaScript work?

02

Which Open Graph tags are required, and which X card tag do you need?

03

What size should a sharing image be, and what else should you check about it?

04

Why must og:image and og:url be absolute URLs?

How X falls back to Open Graph

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

title: Learn HTML for free
description: Live examples, exercises with automatic checks.
image: https://hectal.in/og?title=HTML