Sub topic 7
Twitter/X Cards and Fallback to Open Graph
This chapter assumes you can write a page <head>, know the difference between absolute and relative URLs, and have already added the four core Open Graph properties (og:title, og:type, og:url, og:image) from earlier chapters.
Why Twitter/X has its own tags
Twitter/X had its own card markup before Open Graph was widely used. Its crawler still reads that markup. It also reads Open Graph tags when the Twitter-specific ones are missing. That fallback means you rarely need to duplicate your data.
The one tag you cannot skip is twitter:card. It selects the card layout, and Open Graph has no equivalent for it.
The card types
| `twitter:card` value | Layout |
|---|---|
| `summary` | Small square thumbnail beside the title and description |
| `summary_large_image` | Large image above the title and description |
If twitter:card is missing, X may still show a basic link preview, but you do not control the layout. Set it explicitly.
How the fallback works
For each piece of card data, the crawler looks for the Twitter tag first. If it is absent, it uses the Open Graph tag.
| Card data | Twitter tag | Falls back to |
|---|---|---|
| Title | `twitter:title` | `og:title` |
| Description | `twitter:description` | `og:description` |
| Image | `twitter:image` | `og:image` |
| Image alt text | `twitter:image:alt` | `og:image:alt` |
| Card layout | `twitter:card` | none |
A minimal setup
The smallest useful setup adds one Twitter tag to the Open Graph tags you already have:
<meta name="twitter:card" content="summary_large_image">
<meta property="og:title" content="How to Brew Cold Coffee">
<meta property="og:description" content="A simple method for smooth cold-brew coffee at home.">
<meta property="og:image" content="https://example.com/images/cold-coffee-1200x630.jpg">The crawler builds a large-image card. The title, description, and image all come from the og: tags.
Notice the attribute names. Open Graph tags use property. Twitter tags conventionally use name. Most parsers accept either, but following the convention avoids surprises with stricter tools.
When to override
Add Twitter-specific tags only when the card should differ from the Open Graph preview. For example, you may want a shorter title on X, or a different crop of the image:
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Cold Brew in 5 Steps">
<meta property="og:title" content="How to Brew Cold Coffee at Home: A Complete Guide">
<meta property="og:image" content="https://example.com/images/cold-coffee-1200x630.jpg">Here X shows "Cold Brew in 5 Steps", while other platforms show the longer og:title. The image still falls back to og:image.
Optional account tags
You can attribute the card to accounts with twitter:site (the site's account) and twitter:creator (the author's account). Both take a handle such as @examplecoffee. These are not required for the card to render.
Common errors
- No
twitter:card. The layout is uncontrolled. Add it. - Relative image URLs.
content="/images/cover.jpg"is not reliable. Use an absolutehttps://URL. - Image too small or too large. Large-image cards work best with the 1200×630 image from the previous chapter. Very small images may fall back to the
summarylayout, or be dropped. - Changing tags and seeing no change. X caches card data. Updating the HTML does not refresh a link that was already crawled. The caching chapter covers refreshing.
- JavaScript-only tags. The crawler reads the server response and does not run your scripts. Tags added in the browser are not seen.
Exercise
A page has og:title, og:description, and og:image set, but no Twitter tags at all. Which single tag should you add so X shows a large-image card, and where do the title, description, and image come from?
Show answer
Add <meta name="twitter:card" content="summary_large_image">. The title, description, and image fall back to the og:title, og:description, and og:image values, because no twitter:title, twitter:description, or twitter:image tags are present.
Exercise
You set og:title to "How to Brew Cold Coffee at Home: A Complete Guide" and twitter:title to "Cold Brew in 5 Steps". What title appears on X and what title appears on a platform that reads only Open Graph?
Show answer
X shows "Cold Brew in 5 Steps", because the Twitter tag takes priority. The Open Graph-only platform shows "How to Brew Cold Coffee at Home: A Complete Guide".