DEV Community

Cover image for Open Graph Checker: Test Link Previews on Facebook, X, Slack
devTalk
devTalk

Posted on Originally published at dev-talk.com

Open Graph Checker: Test Link Previews on Facebook, X, Slack

Last updated: 25 November 2026. I could not run the checker itself from my environment. The checks and thresholds below come from its page, and the script I include was written and run by me against local test pages. SeeHow this was checked.

You publish a post, paste the link into Slack or LinkedIn, and get a bare URL, a tiny thumbnail, or the wrong image. The cause is almost always in the page's <head>: a missing og:image, an image that is too small, or a firewall that blocks the crawler. The Open Graph Preview Checker on Dev Talk shows the preview and lists what is wrong. This article covers what it checks, how to read the results, how to fix the common failures, and how to run the same checks from a script.

What the tool does

You type a page address into a single field and press Check. According to the page, the tool then:

  • shows previews of how the link will look when shared on Facebook, X, LinkedIn, WhatsApp and Slack;
  • flags og: and twitter: tags that are missing or wrong, naming og:title, og:description, og:image and twitter:card;
  • loads the share image to check that it loads and measure it;
  • lists problems with errors first (no image, image too small, image not loading) and warnings after them, and offers recommended tags to copy into your <head>.

There is no score and no pass or fail label, only that errors-then-warnings ordering. It has a URL field only; the page mentions no option to paste HTML, so it can check a page only once it is reachable. That matters for staging sites behind a login, which the tool cannot see, as it cannot see any page that requires authentication.

The page says it reads the head "like the Facebook and X crawlers do" and that it needs JavaScript. It does not explain which steps run in your browser and which, if any, go through a server. It says results are cached for a few minutes to speed up repeat checks and that no list of checked sites is stored. I could not verify those statements.

The image rules it applies

These are the numbers the page states for the share image. They are the tool's guidance, not an official specification from every platform, so treat them as practical targets:

Condition What the page says happens
1200 × 630 pixels (1.91:1), JPG, PNG or WebP The recommended size and format.
File size under about 300 KB Recommended so WhatsApp also shows it.
Under 600 × 315 The image becomes a small thumbnail.
Under 200 × 200 Facebook ignores the image.
SVG Never shown.

The tags you actually need

The page's guidance is that, besides the og: tags, only twitter:card is needed: X reads og:title, og:description and og:image, but setting twitter:card to summary_large_image is what asks for the large image card. A head that covers that, plus the usual Open Graph basics, looks like this:

<head>
  <title>My Post | Example</title>
  <meta property="og:type" content="article">
  <meta property="og:title" content="My Post">
  <meta property="og:description" content="One or two sentences that make someone click.">
  <meta property="og:url" content="https://example.com/blog/my-post">
  <meta property="og:image" content="https://example.com/images/my-post-1200x630.jpg">
  <meta property="og:image:width" content="1200">
  <meta property="og:image:height" content="630">
  <meta property="og:image:alt" content="Describe the image in a few words">
  <meta name="twitter:card" content="summary_large_image">
</head>
Enter fullscreen mode Exit fullscreen mode

Use an absolute URL for og:image and og:url, including the scheme and host. The width, height and alt tags are optional parts of the Open Graph protocol; they help but the tool names only the four tags above as checked.

In a Laravel app, the page's FAQ suggests putting the tags in the layout's <head> and filling them from the post, or using a package such as artesaos/seotools. A Blade version of the head above:

<head>
    <meta property="og:type" content="article">
    <meta property="og:title" content="{{ $post->title }}">
    <meta property="og:description" content="{{ \Illuminate\Support\Str::limit(strip_tags($post->excerpt), 150) }}">
    <meta property="og:url" content="{{ route('posts.show', $post) }}">
    <meta property="og:image" content="{{ asset($post->share_image) }}">
    <meta name="twitter:card" content="summary_large_image">
</head>
Enter fullscreen mode Exit fullscreen mode

I did not render that Blade snippet in an application. Blade's double braces escape their output, which is what you want for titles and descriptions. Generate each post's share image as a fixed 1200 × 630 file so asset() returns a stable URL.

Fixing the common failures

No preview at all, or a 403

The page warns that firewalls and bot protection can return HTTP 403 to crawlers, so shared links get no preview. The fix it gives is to allow the facebookexternalhit, Twitterbot and LinkedInBot user agents. Check your CDN or WAF rules and any "block bots" setting first. I reproduced this symptom locally: a test server that returns 403 to the facebookexternalhit user agent made my script fail with HTTP Error 403: Forbidden, while the same URL fetched with a browser user agent worked. Allow-listing by user agent string is easy to spoof, so if that bothers you, use your WAF vendor's verified-bot features instead.

Old preview still showing after a fix

According to the page, Facebook, LinkedIn and WhatsApp can keep an old preview for days. It recommends their debugging tools to force a rescrape, and says X updates within a few days. Fix the tags first, confirm them with the checker, then ask each platform to refresh.

Image missing, too small or too heavy

Check that the og:image URL returns the image to an anonymous visitor. It must not sit behind a login, a hotlink rule or a redirect to an HTML page. Then compare its dimensions and file size with the table above. A 400 × 200 image, for example, falls under the 600 × 315 line and becomes a thumbnail.

Run the same checks from a script

A browser tool is fine for one page. To catch regressions across a site, run a script in CI. This Python script fetches a page with a Facebook crawler user agent, reads the og: and twitter: tags from the head, loads og:image and compares it with the thresholds above. It needs Pillow (pip install pillow) and exits with 1 when it finds problems:

#!/usr/bin/env python3
"""Minimal Open Graph check: fetch a page, read og:/twitter: tags, measure og:image."""
import io
import sys
import urllib.request
from html.parser import HTMLParser
from urllib.parse import urljoin

from PIL import Image  # pip install pillow

UA = "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uagent.php)"

class MetaParser(HTMLParser):
    def __init__(self):
        super().__init__()
        self.tags = {}
        self.in_head = True

    def handle_starttag(self, tag, attrs):
        if tag == "body":
            self.in_head = False
        if tag != "meta" or not self.in_head:
            return
        a = dict(attrs)
        key = a.get("property") or a.get("name")
        if key and (key.startswith("og:") or key.startswith("twitter:")):
            self.tags.setdefault(key, a.get("content", ""))

def fetch(url, ua=UA):
    req = urllib.request.Request(url, headers={"User-Agent": ua})
    with urllib.request.urlopen(req, timeout=15) as r:
        return r.read(), r.headers.get_content_type()

def main(url, ua=UA):
    problems = []
    try:
        body, _ = fetch(url, ua)
    except Exception as e:
        print(f"ERROR fetching page as {ua.split('/')[0]}: {e}")
        return 1

    p = MetaParser()
    p.feed(body.decode("utf-8", "replace"))
    t = p.tags

    for key in ("og:title", "og:description", "og:image", "twitter:card"):
        if not t.get(key):
            problems.append(f"missing {key}")

    img = t.get("og:image")
    if img:
        if not img.startswith(("http://", "https://")):
            problems.append(f"og:image is not an absolute URL: {img}")
        try:
            data, ctype = fetch(urljoin(url, img), ua)
            if ctype == "image/svg+xml":
                problems.append("og:image is SVG (never shown)")
            else:
                w, h = Image.open(io.BytesIO(data)).size
                kb = len(data) / 1024
                print(f"image: {w}x{h}, {kb:.0f} KB, {ctype}")
                if w < 200 or h < 200:
                    problems.append("image under 200x200: Facebook ignores it")
                elif w < 600 or h < 315:
                    problems.append("image under 600x315: shown as a small thumbnail")
                elif (w, h) != (1200, 630):
                    problems.append(f"image is {w}x{h}, recommended 1200x630")
                if kb > 300:
                    problems.append(f"image is {kb:.0f} KB, aim for under about 300 KB")
        except Exception as e:
            problems.append(f"og:image failed to load: {e}")

    for k, v in t.items():
        print(f"{k} = {v}")
    for pr in problems:
        print("PROBLEM:", pr)
    return 1 if problems else 0

if __name__ == "__main__":
    sys.exit(main(sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else UA))
Enter fullscreen mode Exit fullscreen mode

Run it as python3 check_og.py https://example.com/blog/my-post, optionally followed by a user agent string to test how a different crawler is treated. I ran it against local test pages. The results:

  • A page with a 1200 × 630 image, title, description and card tag: exit code 0.
  • No og:image: missing og:image.
  • A relative og:image of /good.png: it still loaded, but I flagged og:image is not an absolute URL. That check is my addition, not something the tool page states.
  • A 400 × 200 image: shown as a small-thumbnail warning. A 150 × 150 image: flagged as ignored by Facebook.
  • A 1200 × 630 PNG of 2,216 KB: flagged for size.
  • An SVG: flagged as never shown. A 404 image URL: og:image failed to load.
  • A page that returns 403 to the facebookexternalhit user agent: the fetch failed, and the same page passed with a browser user agent.

The script is deliberately small. It reads only meta tags before <body>, does not follow redirects specially, does not run JavaScript, and does not check og:url or og:type. Single-page apps that inject tags with JavaScript will fail it, and real crawlers generally do not run JavaScript either, so serve the tags in the initial HTML or render them server-side.

Limits of any checker

  • A checker sees what one fetch returns. Crawlers differ in headers, timeouts and IP ranges, so a page can pass here and still fail on a platform. The platforms' own debugging tools are the final word.
  • Previews are the tool's rendering of each platform. I did not compare them with the real platforms, and platforms change their cards.
  • Pages behind a login, a paywall or an IP allow list cannot be checked from the outside.

Related Dev Talk articles

Frequently asked questions

What is an Open Graph checker?

A tool that fetches a page, reads its Open Graph and Twitter card tags, and shows how a shared link will look, with warnings for missing or wrong tags and images.

What size should an Open Graph image be?

The page recommends 1200 × 630 pixels (1.91:1) as JPG, PNG or WebP, under about 300 KB. Under 600 × 315 it becomes a small thumbnail, and under 200 × 200 Facebook ignores it.

Which tags do I need for X (Twitter)?

According to the page, X reads og:title, og:description and og:image, and twitter:card set to summary_large_image requests the large image card.

Why does my link preview show nothing?

A firewall or bot protection may be returning 403 to the crawler. Allow the facebookexternalhit, Twitterbot and LinkedInBot user agents and check again.

Why is my old preview still showing?

Platforms cache previews, in some cases for days. Use the Facebook, LinkedIn or WhatsApp debugging tools to force a rescrape.

Can I check a page before it is public?

Not with this tool, which only accepts a URL. A staging page that requires a login cannot be fetched from outside, so test with a script on the server or make it temporarily reachable.

update log

  • 25 November 2026: first version.
  • To recheck on each update: the tool's checked tags and thresholds, each platform's current image guidance, and real checker output to add as examples.

Sources


Originally published on DEV Talk.

Top comments (0)