Ability to add structured data to head.tsx in /app #44629
Replies: 3 comments 1 reply
-
I have tried the same but it is working on my localhost but not on the production url. Although I can see it when I am inspecting the page but unable to find it in the page source. Any help will be appreciated. `import React from "react"; interface ClientScriptProps { function ClientScript({ data }: ClientScriptProps) { {/* Add JSON-LD to your page /} <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }} /> {/ ... */} ); } export default ClientScript; |
Beta Was this translation helpful? Give feedback.
-
I have the same problem:
|
Beta Was this translation helpful? Give feedback.
-
If anyone is struggling with this, I found out that as per the Google Search Central documentation and the Rich Results Test it should be absolutely fine to have structured data in the body. This is also the solution presented by the Next.js documentation. If anyone needs dynamic data and still prefers the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the feature you'd like to request
I would like to be able to add structured data to a Next.js 13 website using the appDir. This was a related discussion in app directory feedback.
Describe the solution you'd like
I would like to be able to add structured data to
head.tsx
in a similar way to this:Describe alternatives you've considered
It "works", but it is in the body and not the head.
Beta Was this translation helpful? Give feedback.
All reactions