Add a Link Preview Smoke Test to Your Deploy Pipeline (Node Script + GitHub Actions)
We test our APIs, our components, and sometimes our CSS. Then a release goes out, marketing drops the new page into a Slack channel and a LinkedIn post, and the card shows last month's image with a title that ends in "| Home". Link previews break silently. No error page, no failed request in your logs, nothing in Sentry. The first signal is usually a screenshot from someone outside the team. So I…
In the article, the author discusses the importance of testing link previews after deploying a site. They explain that link previews can break silently, with no error page or failed request in logs. The first sign of a problem is usually a screenshot from someone outside the team. The author created a small, dependency-free Node script to check the Open Graph and Twitter Card tags on a list of production URLs. This script, along with a GitHub Actions job, is run after each deploy.
The author suggests asserting a few key points:
1. You don't need to test everything in the head.
2. Common failures include missing or duplicate meta tags, incorrect image URLs, and wrong URLs.
3. Social crawlers don't execute JavaScript, so a plain fetch test is closer to reality than a headless browser.
The provided script, named scripts/check-previews.mjs, uses Node 18+'s built-in fetch function and can be saved with no additional installation required. It checks for missing or duplicate meta tags, image URLs, and the Twitter card attribute. The script uses a list of production URLs and a User-Agent string for the fetch requests.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.