How to Fix Next.js Open Graph Images Not Showing

At a glance
Request the deployed article and inspect the delivered metadata for og:title, og:description and og:image. Copy the resolved image URL and open it without signing in. A correct tag cannot compensate for an image behind authentication.
When a link preview appears without an image in a messaging app or social network, the problem is often not the image itself. The page may be publishing an incorrect Open Graph URL, the image may not be publicly reachable, or the preview service may still be using cached metadata.
This guide walks through a practical troubleshooting process for a Next.js App Router site. Social platforms can interpret and cache previews differently, so validate the actual HTML and test each target platform rather than assuming one result applies everywhere.
Check the HTML and the image as separate resources
Request the deployed article and inspect the delivered metadata for og:title, og:description and og:image. Copy the resolved image URL and open it without signing in. A correct tag cannot compensate for an image behind authentication.
If the URL returns HTML, a redirect loop or a 404, fix that first. If it returns an image, check its format, dimensions and whether the target sharing service can fetch it. Sharing platforms cache previews, so use their current inspection tool to request a refresh after the underlying issue is fixed.
Check the article-specific metadata rather than only the homepage defaults. A nested metadata override can change what the route outputs. Keep a record of the exact URL tested, including trailing slash and hostname, so a successful test on one domain does not hide a failure on another.
Reference: Next.js metadata file conventions.
1. Confirm the page outputs Open Graph metadata
Open the deployed page and inspect its HTML source or browser developer tools. Look for tags similar to:
<meta property="og:title" content="Your article title" />
<meta property="og:description" content="A short article summary" />
<meta property="og:image" content="https://example.com/images/article-cover.jpg" />
<meta property="og:url" content="https://example.com/blog/example" />
The important detail is that og:image should point to an image URL that the preview crawler can fetch. A path that works only in your local development environment is not enough.
2. Configure metadataBase for relative URLs
In the App Router, you can define shared metadata in a layout and use metadataBase to resolve relative metadata URLs:
import type { Metadata } from "next";
export const metadata: Metadata = {
metadataBase: new URL("https://www.example.com"),
title: {
default: "Example Site",
template: "%s | Example Site",
},
};
Replace the example domain with your real canonical production origin. Do not leave a preview or localhost domain in production metadata. If your project supports several environments, review how the production origin is configured so that builds do not accidentally publish the wrong URL.
Reference: https://nextjs.org/docs/app/api-reference/functions/generate-metadata
3. Set Open Graph metadata for the article
A page can provide its own Open Graph title, description, and image:
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "A Practical Next.js Guide",
description: "A concise guide with tested examples.",
openGraph: {
title: "A Practical Next.js Guide",
description: "A concise guide with tested examples.",
url: "https://www.example.com/blog/practical-nextjs-guide",
siteName: "Example Site",
images: [
{
url: "https://www.example.com/Images/blog/practical-nextjs-guide.jpg",
width: 1200,
height: 630,
alt: "A visual guide to Next.js",
},
],
type: "article",
},
};
The values above are examples. Use the real URL, title, description, dimensions, and alternative text for your article. If your project uses generateMetadata, check that its returned object includes the expected Open Graph fields and that nested metadata is merged as intended.
4. Check the image path and deployment
If an image is stored in the Next.js public directory, it is normally served from the root URL without the word public. For example:
- File:
public/Images/blog/article-cover.jpg - Public URL path:
/Images/blog/article-cover.jpg
Open the full production image URL directly in a private browser window. Confirm that it returns the correct image without authentication, redirects to a login page, or returns a 404. Check capitalization too: a path that works on one local filesystem may fail on a case-sensitive production host.
If you use a remote image host, verify that the URL remains accessible to crawlers and does not expire. An image displayed through next/image is not automatically the same thing as the og:image metadata URL; inspect the metadata that is published.
5. Consider Next.js file-based metadata images
The App Router supports file conventions such as opengraph-image.jpg and dynamically generated Open Graph images. These conventions can be useful when each route needs a predictable social image. Review the current documentation for supported file names, formats, and route behavior before mixing file-based images with manually configured metadata.
Reference: https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image
6. Test the deployed HTML, not just the React component
Use this checklist after deployment:
- Open the exact production URL.
- Inspect the generated HTML and find
property="og:image". - Copy the image URL and open it directly.
- Confirm that the image is public and returns a successful response.
- Check the canonical URL and ensure it is not localhost or a preview deployment.
- Test the link with the official preview/debugging tool for the platform you care about, if available.
- If the HTML is correct but the preview remains stale, use the platform's refresh/debugging option where available and allow for caching.
A browser-rendered page can look correct even when the metadata in the original HTML is wrong. Preview crawlers may not execute the same JavaScript as a full browser, so server-published metadata is important.
7. Common causes and likely fixes
- Symptom: No
og:imagetag; What to check: Page metadata,generateMetadata, or file-based metadata convention - Symptom: Image URL starts with an unexpected domain; What to check:
metadataBaseand deployment environment - Symptom: Image URL returns 404; What to check: File location, filename case, and deployment output
- Symptom: Preview works on one platform but not another; What to check: Platform-specific caching and crawler behavior
- Symptom: New image does not replace old preview; What to check: Cached preview; use the platform's supported refresh tool
- Symptom: Local image works but production fails; What to check: Public path, case sensitivity, redirects, or access restrictions
Frequently asked questions
Does next/image automatically set og:image?
No. The visual image component and social metadata solve different jobs. You should explicitly check the page's Open Graph metadata or use the appropriate Next.js metadata file convention.
Should og:image be an absolute URL?
An absolute, publicly accessible production URL is the safest way to debug preview issues. Next.js also supports resolving relative metadata URLs through metadataBase, but inspect the final generated URL to ensure it is correct.
Why does the preview still show the old image?
Preview services may cache page metadata or images. After confirming that the deployed HTML and image URL are correct, use the relevant platform's supported debugging or refresh process.
Research and references
- Next.js Metadata and
generateMetadata— https://nextjs.org/docs/app/api-reference/functions/generate-metadata - Next.js Open Graph Image convention — https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image
- Next.js Metadata and OG Images guide — https://nextjs.org/docs/app/getting-started/metadata-and-og-images
- Google Search Central: image SEO best practices — https://developers.google.com/search/docs/appearance/google-images
If a generated thumbnail also fails on the page itself, use the Next.js image 400 checklist to separate optimisation errors from sharing metadata problems.
Try our QR Code Generator
Create clean, scannable QR codes for testing websites, URLs, and client handoffs.

Ukasha Altaf
Software Developer & Digital Tools Creator
Founder of Ukasha Mart. Building free, accessible browser-based utilities and writing in-depth tutorials on modern technology, freelancing, and practical online work.
Explore Further