-
Notifications
You must be signed in to change notification settings - Fork 27.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEXT-666] Nested Open Graph metadata overwrites root metadata #46434
Comments
Same thing happens for |
As the documentation mentioned, it's by designed, you need to speicify the full information as well. We merged the first layer of properties, but we don't merge the deeper layers of those properties.
One bad case might happen could be when you don't want to specify some property, but it might accidently deep merge with the few layers away topper level metadata, resulting in unexpected metadata. |
In our case properties that are dynamic are not included in metadata for root layout, so this exact issue you described does not happen. If objects are not deep merged then in most cases specifying this in root layout does not make sense and should not be done.
I did not interpret this line in documentation as "objects won't be deep merged", in fact I understood the opposite of it. If the decision on deep merging is final can the documentation be more clear about this? |
@pf1gura we're tracking the doc updates internally so I'll close this issue for now 🙏 Will rephrase the description on beta docs later |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
Metadata (metadata, generateMetadata, next/head, head.js)
Link to the code that reproduces this issue
https://github.com/vxna/next-nested-metadata-merge-repro
To Reproduce
Navigate the index and nested page back and forth and check meta tags in devtools:
CleanShot.2023-02-26.at.10.37.58.mp4
Describe the Bug
Existing Open Graph metadata keys from the root layout aren't getting merged, but completely overwritten with the nested page metadata. That leads into the unused (at the nested page level) keys like
type
,siteName
orurl
are just gone.https://github.com/vxna/next-nested-metadata-merge-repro/blob/main/app/layout.tsx#L32-L45
https://github.com/vxna/next-nested-metadata-merge-repro/blob/main/app/nested/page.tsx#L18-L27
Expected Behavior
https://beta.nextjs.org/docs/api-reference/metadata#ordering
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-666
The text was updated successfully, but these errors were encountered: