Twitter card
Use twitter:card, twitter:title and twitter:image.
What is a Twitter card?
Twitter (X) and other platforms show a special card when a link is shared. That card is built with Twitter card tags and is separate from Open Graph.
Twitter card tags use the form <meta name="twitter:...">; here you use name, not property. The three essential tags are twitter:card, twitter:title and twitter:image.
twitter:title and twitter:image
twitter:title is the title of the card. If og:title is defined in Open Graph, Twitter may fall back to it; but write both to be explicit.
twitter:image is the URL of the card image. For the summary_large_image card, an image around 1200x628 pixels is recommended. Use an absolute URL with https.
Using it together with Open Graph
Twitter card and Open Graph are usually written together. Twitter looks at twitter:* tags first, then falls back to og:* tags. So writing only Open Graph also works; but to fully control the card, add the twitter:* tags too.
If twitter:image is missing, og:image is used. The same rule applies to the description.
Exercise Add Twitter card tags for a blog
Add three Twitter card tags to the head for a blog post: <meta name="twitter:card" content="summary_large_image">, <meta name="twitter:title" content="..."> and <meta name="twitter:image" content="https://...">.
Show example solution
<head>
<title>Blog Post</title>
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Blog Post: Web Design">
<meta name="twitter:image" content="https://alexblog.com/cover/design.jpg">
</head>
Test yourself
-
Complete the twitter:card tag
<meta name="twitter:card" content="____">Show answer
<meta name="twitter:card" content="summary_large_image"> -
What value does twitter:card take?
<meta name="twitter:card" content="?">- summary_large_image
- <meta>
- og:title
- <link>
Show answer
summary_large_image — Correct. summary_large_image is the large-image card type.
-
Match the Twitter property with its role
- twitter:card
- Card type
- twitter:title
- Card title
- twitter:image
- Cover image
- twitter:description
- Card description