Sub topic 12
Common pitfalls and troubleshooting
This chapter assumes you have read the earlier chapters. You should know the four core properties, how og:image works, and how to check a page with curl. Most broken previews come from a small set of causes. Check them in order, starting with what the crawler actually received.
A triage order
Work from the raw HTML outward. Start by checking what the server returns. Then check the tag values, then the image, then the platform cache.
Tags the crawler never sees
Crawlers generally do not run JavaScript. If your framework inserts tags in the browser after load, the crawler gets a page with no og: tags. Check with the same request a crawler makes:
curl -s -A "facebookexternalhit/1.1" https://example.com/cold-coffee | grep -i 'property="og:'If this prints nothing but the browser's developer tools show the tags, render them on the server or at build time.
Other causes of the same symptom:
- The page redirects to a login screen or a cookie wall, so the crawler reads that page instead.
- A firewall, bot filter, or
robots.txtrule blocks the crawler's user agent. - The tags sit in
<body>or after a malformed element, so the parser does not treat them as part of<head>.
Malformed tag markup
Three mistakes account for most markup problems:
- Using
nameinstead ofpropertyfor Open Graph tags. Twitter tags usename. Open Graph tags useproperty. - Leaving quotes or
&unescaped incontent. A title likeThe "Best" Brewcuts the attribute short. - Repeating a single-value tag, such as two
og:titlelines from a theme and a plugin. Crawlers may pick either one.
<!-- Broken: wrong attribute, unescaped quotes -->
<meta name="og:title" content="The "Best" Brew">
<!-- Correct -->
<meta property="og:title" content="The "Best" Brew">URL problems
Relative URLs in og:image or og:url fail, because the crawler has no base to resolve them against. Use full https:// URLs.
Keep og:url equal to the canonical address of the page. If it differs from the address that was shared, platforms may merge share counts under one URL or fetch the other one. A mismatch between http and https, or between www and the bare domain, causes this often.
Image problems
The image is the most common cause of a card that shows text but no picture.
- The file is too small. Many platforms drop images below a minimum size. Use 1200×630 pixels as the default.
- The file is too large or too slow. Some crawlers give up after a few seconds or a few megabytes. Keep it well under a few megabytes.
- The format is unsupported. Use JPEG or PNG. WebP and SVG are not accepted everywhere, and SVG usually is not.
- The image URL requires cookies, a signed token that expires, or hotlink protection that rejects the crawler.
- The URL is correct, but the image changed. Platforms cache the image by URL, so give a new image a new filename.
Stale previews
If curl shows correct tags but the card is old, the platform cache is the cause. Platforms store the first scrape, often for days. Re-scrape through the platform's debugging tool, as covered in the caching chapter. Messaging apps with no debugger usually need a changed URL, for example a query string like ?v=2. Confirm that your canonical og:url still points to the clean address.
Quick reference
| Symptom | Likely cause | Fix |
|---|---|---|
| No card at all | Tags added by JavaScript, or crawler blocked | Render on the server; allow the crawler |
| Title shows as the page URL | `og:title` missing or malformed | Check `property` and escaping |
| Text but no image | Relative, small, blocked, or unsupported image | Absolute 1200×630 JPEG or PNG |
| Old title or image | Platform cache | Re-scrape; change the image filename |
| Wrong page in card | Redirect or `og:url` mismatch | Match `og:url` to the canonical URL |
Exercise
A teammate's blog post shows the correct title in the browser developer tools, but sharing it produces a card with no image or description. Running curl -s -A "facebookexternalhit/1.1" URL | grep -i 'property="og:' prints nothing. What is the most likely cause, and what should they change?
Show answer
The tags are added by client-side JavaScript, which the crawler does not run, so the HTML it receives has no Open Graph tags. They should render the tags on the server or at build time, so they appear in the initial HTML response. Re-running the curl command should then print the tags. After that, they should re-scrape the URL in the platform's debugging tool to clear the cached result.