Opengraph file-based metadata are not inherited like layouts #50353
Replies: 3 comments 1 reply
-
To expand on this issue, it seems like overwriting any part of |
Beta Was this translation helpful? Give feedback.
-
Encountering similar behaviour as well. It seems when using Current BehaviourFor example: // app/layout.tsx
export const metadata: Metadata = {
robots: {
index: true,
follow: true,
'max-snippet': -1,
'max-image-preview': 'large',
'max-video-preview': -1,
},
//...
}; Will produce the following: <meta name="robots" content="index, follow, max-video-preview:-1, max-image-preview:large, max-snippet:-1"> If additionally, in some sub-route: // app/somePath/page.tsx
export const metadata: Metadata = {
robots: {
index: false,
follow: false,
},
//...
}; The other properties get lost: <meta name="robots" content="noindex, nofollow">
<!-- Missing: max-video-preview:-1, max-image-preview:large, max-snippet:-1 --> Note: you likely wouldn't need max-snippet etc. if using noindex, but this is just an example to demonstrate the issue. Similar behaviour occurs with There doesn't seem to be a good workaround as far as I can tell currently. I tried using export async function generateMetadata(
parent: ResolvingMetadata
): Promise<Metadata> {
//optionally access and extend (rather than replace) parent metadata
const existingMetadata: Metadata = (await parent);
return {
robots: {
...existingMetadata.robots,
index: false,
follow: false,
},
//...
};
} ...but this didn't work as apparently I'd be interested to know whether this is intended behaviour or an issue that needs to be created/addressed. New to NextJS 13 having upgraded recently from 12 so would love to hear if there's something I'm missing somewhere. |
Beta Was this translation helpful? Give feedback.
-
This still seems to be a thing in |
Beta Was this translation helpful? Give feedback.
-
Hey there!
It was my understanding that icon.png and layout.tsx/jsx would be inherited from the root by all pages under it, right? That works.
But, an opengraph-image.jpg does not get inherited to all children pages, which poses a problem, I need to manually copy the file to all subfolders.
Beta Was this translation helpful? Give feedback.
All reactions