TechBuzzPro

Open Graph Tags Work Locally But Not Online? Fix It

· 7 min read · Apps & Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Open Graph tags control how your pages appear when shared on Facebook, LinkedIn, X, and other platforms. When they work in your local preview but fail online, the usual culprits are caching, blocked crawlers, wrong URLs, or missing server headers. This guide walks you through the most common causes and fixes, step by step, so your shared links show the right title, description, and image.

What You'll Need

  • Access to your site's HTML source (via your CMS, code editor, or hosting file manager)
  • The ability to edit your site's <head> section or use an SEO plugin
  • A way to view your site's public URL (not just localhost)
  • Optional: a command-line tool like curl or a browser's developer tools
  • Accounts on the platforms you're testing (Facebook, LinkedIn, X, etc.) or use their debugging tools

Step-by-Step

  1. Confirm the tags exist in the public HTML. Open your live page in a browser, right-click and select "View Page Source" (or use Ctrl+U / Cmd+U). Search for og:. If you don't see the tags, your CMS or theme may be stripping them, or you're editing a cached version. Check that your edits are actually deployed to the live server.
  2. Check for duplicate or missing tags. Look for multiple og:title or og:image tags. Some plugins or themes add their own, conflicting with yours. Use a validator (like the ones in step 6) to see which tags the platform sees. Remove duplicates and ensure each property appears only once.
  3. Verify the og:url tag matches the canonical URL. The og:url should be the exact, full URL of the page (including https:// and www if applicable). If it's a relative path or missing, platforms may ignore your tags. If you use URL shorteners or tracking parameters, the og:url should still point to the clean, canonical version.
  4. Test the og:image URL directly. Copy the image URL from your og:image tag and paste it into a new browser tab. If it doesn't load or shows an error, fix the URL. Ensure the image is at least 1200x630 pixels (Facebook's recommended size) and under 8MB. Also, check that the image file is publicly accessible—not blocked by hotlink protection or a login wall.
  5. Check for server-side redirects. If your site redirects (e.g., from http to https, or from www to non-www), the crawler may follow the redirect and lose the OG tags. Use a tool like Redirect Checker to see the full redirect chain. Ideally, the final URL should serve the OG tags directly. If not, update your canonical URLs or server config to avoid redirects on the final page.
  6. Use platform debuggers to clear caches. Each major platform caches your OG data. After fixing your tags, you must force a refresh:
    • Facebook / LinkedIn: Go to the Facebook Sharing Debugger, paste your URL, and click "Scrape Again". This clears the cache and fetches fresh data.
    • X (Twitter): Use the Twitter Card Validator (though it may be deprecated, it still works for some). Alternatively, tweet the link and check the preview.
    • Pinterest: Use the Rich Pins Validator.
    • Slack / Discord / iMessage: These often cache aggressively. Try adding a query string like ?v=2 to the URL when testing, or use their "unfurl" endpoints if available.
  7. Test with a fresh URL. If the debugger still shows old data, append a dummy query parameter (e.g., ?fbclid=test or ?refresh=123) to the URL and test that. If the new URL shows correct tags, the issue is purely caching. If not, your tags are still wrong.
  8. Check for crawler blocking. Look at your robots.txt file. If it disallows crawlers like facebookexternalhit or Twitterbot, they can't fetch your page. Also, check your server logs to see if these bots are actually hitting your site. If not, your hosting may be blocking them via .htaccess or firewall rules.
  9. Verify server response headers. Use curl -I on your page URL to see the response headers. Look for Content-Type: text/html and 200 OK. If you see a 301 or 302, the crawler may not follow it. Also, check that the Content-Length is not zero—some servers return an empty body for bot requests.
  10. Test with a command-line tool. Use curl with a custom user-agent to see exactly what a crawler sees. For example:
    curl -A "facebookexternalhit/1.1" https://yourdomain.com/page
    This shows the HTML that Facebook gets. If the OG tags are missing, your server is serving different content to bots (this can happen with JavaScript-rendered sites).
  11. If your site is a JavaScript single-page app (SPA), ensure server-side rendering or prerendering. Platforms like Facebook do not execute JavaScript. If your OG tags are injected via JS, they won't be seen. You need to either use a static HTML version for bots, or use a service like Prerender.io, or implement server-side rendering for the head section.

Common Mistakes

  • Using relative URLs for og:image or og:url. They must be absolute (starting with https://).
  • Forgetting the og:type tag. While not always required, it's good practice to include og:type (e.g., "website" or "article").
  • Testing on localhost. Localhost is not accessible to crawlers. You must test on a publicly accessible URL, even if it's a staging server.
  • Ignoring image dimensions. Some platforms reject images that are too small or have the wrong aspect ratio. Always use at least 1200x630 for Facebook and LinkedIn.
  • Using a URL with tracking parameters in og:url. This can cause the canonical URL to be different, leading to inconsistent shares.

Tips

  • Use an SEO plugin (like Yoast SEO or Rank Math for WordPress) that automatically generates OG tags. This reduces manual errors.
  • Always use HTTPS for your og:image and og:url. Mixed content can cause issues.
  • Test your tags with the OpenGraph.xyz validator—it shows exactly what most platforms see.
  • Cache your OG tags in a static HTML file if you have a dynamic site. This ensures fast, consistent delivery.
  • When you change an image, update the image file name or add a version query to force platforms to re-fetch it.

Troubleshooting

If the steps above don't resolve the issue, try these additional checks:

  • Check your CMS's built-in social settings. Some platforms (like WordPress with Jetpack) have their own OG tags that may override yours. Disable them or ensure they match your custom tags.
  • Look at the raw response with curl -L. The -L flag follows redirects. See the final HTML after all redirects. If the OG tags are only on the first response, the redirect is the problem.
  • Test with a different URL structure. If your site uses index.php or query strings, try a clean URL. Some platforms don't handle complex URLs well.
  • Check for CDN caching. If you use Cloudflare or similar, the CDN may be serving a cached version without your new tags. Purge the cache for that URL.
  • Verify that your server isn't gzip-compressing the response for bots in a way that breaks parsing. This is rare, but you can test with curl --compressed.

Frequently Asked Questions

Why do my OG tags work on Facebook but not on LinkedIn?

LinkedIn uses its own crawler and cache. Even if Facebook shows correct data, LinkedIn may have cached an older version. Use LinkedIn's Post Inspector (linkedin.com/post-inspector) to scrape the URL again.

Do I need both og: and twitter: tags?

No. Twitter falls back to og: tags if twitter: tags are missing. However, if you want to customize the Twitter card type (e.g., summary_large_image), you can add twitter:card and twitter:image. But og: tags are sufficient for most cases.

Why does my image not show up even though it's in the og:image tag?

Check that the image URL is publicly accessible (no login required), the image is in a supported format (JPG, PNG, GIF, WebP), and it meets the minimum size requirements. Also, ensure the image URL is absolute and uses HTTPS.

How long does it take for platforms to update after I fix my tags?

It varies. Facebook and LinkedIn update immediately after you use their debugger tools. X (Twitter) may take a few hours. Other platforms like Slack and Discord can cache for days, so you may need to use a URL with a query string to bypass the cache.

Can I use og: tags on a single-page application (SPA) built with React?

Yes, but you need to ensure the tags are present in the initial HTML served to bots. This means using server-side rendering (SSR) or a prerendering service. If you only render client-side, bots won't see the tags.

My og:title shows HTML entities like &quot;. How do I fix that?

Make sure you're not double-encoding your tags. Use plain text in your og:title and og:description. If you're using a CMS, check that the field isn't being escaped twice. Use a validator to see the raw output.