· By John Kavanagh

When a Next.js Child Page Drops Its Open Graph Image

Photograph of a visitor silhouetted in front of a framed exhibit in a dark gallery.
Image by Arzu Sendag, licensed from Unsplash.

The page title changes. The description changes. The page itself looks perfectly respectable. Yet the image we put in the root layout has disappeared from its Open Graph metadata.

This is a fairly small mistake to make with the App Router's Metadata API: give a child page its own openGraph object and assume that Next will fill in everything we left out. It won't merge that nested object in the way we might expect.

My example uses a museum catalogue running Next 13.4.7. The root layout provides a shared image. One exhibit has its own image; another needs the shared one. I also keep a deliberately broken page which changes only the Open Graph title. It is a useful reminder that a page can look finished whilst its head says otherwise.


Start with the Tags That Actually Disappeared

The root layout defines a normal title template and a separate set of Open Graph values:

export const metadata = {
  metadataBase: new URL('https://catalogue.example'),
  title: {
    default: 'Museum Catalogue',
    template: '%s | Museum Catalogue',
  },
  openGraph: {
    title: 'Museum Catalogue',
    siteName: 'Small Museum',
    images: [{
      url: '/shared-card.png',
      width: 1200,
      height: 630,
      alt: 'Blue and cream geometric test card',
    }],
  },
};

The fixture also supplies a general description. These are defaults for pages which don't provide something more specific.

Next introduced this API in version 13.2. It lets layouts and pages describe metadata without manually assembling a collection of head elements. That is helpful, but it doesn't remove the need to understand which values survive when a child supplies its own configuration.

The broken exhibit returns an ordinary title and description, plus openGraph: { title: item.title }. Its heading and browser title are correct. Its ordinary description remains present too. The missing image is therefore quite easy to overlook if the check stops at the browser tab.

I inspect the returned HTML for meta[property="og:image"]. On this page there isn't one. We haven't produced a bad image URL; we haven't produced an image tag at all. Resizing the photograph would be an impressively indirect attempt to fix that.


A Nested Object is Replaced as a Whole

Metadata is resolved through the route's layouts and page. The merge is shallow: the child's openGraph value replaces the inherited openGraph object. Next doesn't separately merge every property inside it.

That explains why changing one Open Graph field can remove several others. The parent image, site name, and description don't survive merely because the child omitted them. Ordinary top‑level metadata, such as description, follows its own inheritance path.

The Next 13 metadata guidance describes this replacement behaviour. I find it easier to remember when the failing example remains beside the corrected one: both render the exhibit, but only one emits the intended sharing metadata.

There is a second distinction here. The normal title template produces Workshop Lamp | Museum Catalogue for the document title. My explicit Open Graph title is simply Workshop Lamp. I check both values rather than assuming that a correct browser title proves a correct sharing title.


Make the Image Choice Explicit

For the corrected route, I use generateMetadata and its parent argument. The parent resolves to the inherited metadata, so I can reuse its images when an exhibit has none of its own:

export async function generateMetadata({ params }, parent) {
  const item = findExhibit(params.slug);
  if (!item) notFound();

  const inheritedImages = (await parent).openGraph?.images ?? [];
  const path = `/fixed/exhibits/${params.slug}`;

  return {
    title: item.title,
    description: item.summary,
    alternates: { canonical: path },
    openGraph: {
      title: item.title,
      description: item.summary,
      url: path,
      siteName: 'Small Museum',
      images: item.image
        ? [{
            url: item.image,
            width: 1200,
            height: 630,
            alt: 'Green and cream geometric test card',
          }]
        : inheritedImages,
    },
  };
}

The imports and small exhibit collection are in my download. The image descriptions refer to its synthetic test cards; an actual catalogue should describe the selected exhibit image.

I deliberately choose between the exhibit image and the inherited images. Appending both would advertise several candidates, which might be appropriate elsewhere, but it isn't the fallback policy I want here. The lamp gets its own green card. The chair gets the shared blue card. Neither page should emit both by accident.

The metadata function and page resolve the same exhibit. An unknown slug calls notFound() rather than borrowing the generic catalogue metadata and pretending that an empty exhibit exists. My fixture keeps the records local so that the example stays about metadata composition, not fetching or caching.


Check Addresses as Well as Images

metadataBase supplies the origin for relative metadata URLs. The lamp's canonical and Open Graph URL should both identify its own page, and its image should resolve to an absolute image address.

This setting does not redirect visitors, publish an image, or check that an address exists. My fixture deliberately uses catalogue.example as its declared production origin whilst running locally. The checks compare the generated metadata against that origin, then fetch the corresponding image path from the local server.

That last request matters. Correct‑looking metadata can still advertise a missing file. The two test cards are actual PNGs, and the checks confirm their dimensions as well as the tags which describe them.

My CMS template SEO checks make a similar point about checking representative content variants. An exhibit with an image and one without an image exercise different decisions. Testing ten exhibits which all have images wouldn't establish that the fallback works.


Follow the Page through Navigation

I start with a production build and request each URL directly. The broken page must demonstrate the missing tag; the corrected pages must each contain exactly one intended image, the expected titles, and their own canonical and Open Graph URLs.

Then I follow the client‑side link from the lamp to the chair and use Back. The selected exhibit and metadata must change together. A correct initial response doesn't prove that moving between records leaves no stale or duplicate tags behind.

This complements my article on JavaScript rendering and SEO checks. The initial response and the document after navigation are different observations, and both are available to inspect without guessing what a crawler might do.

The download automates those checks, includes a missing‑exhibit request, and retains the broken route for comparison. It doesn't claim to reproduce a social platform's cache or preview generator. Once the application emits the right tags and serves the right files, a stale external preview is a separate problem to investigate.

For this particular failure, the correction is small: treat the child's Open Graph object as a complete decision, and carry forward only the parent values the page actually needs.

Postscript

November 2026: The nested‑object replacement described here still needs an explicit fallback. Later Next versions changed other parts of this code: route parameters are asynchronous, and Next 15.2 introduced streamed metadata. When adapting the example, await params and check the completed response or browser document as appropriate; an early HTML chunk may no longer contain the final metadata. My download retains Next 13.4.7, with a newly generated lockfile and the modern verification environment documented in its README.

Downloadable Resource

  • Next.js Metadata Inheritance Lab

    Use this small museum catalogue to inspect a child page which loses its inherited Open Graph image, then compare explicit image selection and fallback.

    Download ZIP

Want to find out more?

If you need senior hands‑on support with a complex React or Next.js platform, migration, performance issue, or technical SEO problem, send me the context and I'll tell you where I can help.