Next.js Discord

Discord Forum

Script tag for structured data not showing in browser head

Answered
Nile Crocodile posted this in #help-forum
Open in Discord
Nile CrocodileOP
I have a Script tag (imported correctly, and other script tags do appear on my website) to add strcutured data for Google SEO purposes. However, it does not show up in my html in my head.

This fixes itself if I change it to a <script/> tag (as in not the nextjs <Script/> tag), or if I put it into the body instead of the next <Head/> element.

Additionally, if I add any other Script tags that aren't the structured data, they show up in the Head

Why is this?

<Script
    id="structured-data-article"
    key="structured-data-article"
    type="application/ld+json"
    dangerouslySetInnerHTML={{
        __html: JSON.stringify({
            // json blob for structured data
        }),
    }}
/>
Answered by Nile Crocodile
Oh is it just that you can't put <Script /> tags in the <Head /> element?
View full answer

1 Reply

Nile CrocodileOP
Oh is it just that you can't put <Script /> tags in the <Head /> element?
Answer