Head doesnt work? #1535
Replies: 3 comments 3 replies
-
How is it rendering a head without the
It's using |
Beta Was this translation helpful? Give feedback.
-
You can find the default document here. I don't quite understand what you're doing, or how you're doing it, but in general if you provide your own {
Document: ({
Html,
Head,
Body,
children,
state: { siteData, routeInfo },
}) => {
return (
<Html lang="en-US">
<Head
defaultTitle="Example.org - The default site title if none is given"
titleTemplate="Example.org - %s"
>
<html lang="en" />
<meta name="description" content="some description" />
<meta name="keywords" content="my, great, keywords, " />
<script id="google-tag-manager">{`
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXX');
`}</script>
</Head>
<Body>{children}</Body>
</Html>
)}
} On pages, or wherever, importing <ProductPage data-page="product">
<Head title={`${name} in ${city.name}, ${state.name} - ${category.name}`}>
{<link rel="canonical" href={seoCanonicalHref} />}
<meta name="description" content={metaDescription} />
<meta name="keywords" content={metaKeywords} />
<script type="application/ld+json">{
JSON.stringify({
"@context": "https://schema.org",
"@type": "MedicalOrganization",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": `https://example.org${rootProductPath(category.slug, state.slug, city.slug, slug)}`
},
"name": name,
"address": address,
"image": [
],
"medicalSpecialty": "Nursing",
"description": seoDescription
}, undefined, 2)
}
</script>
</Head>
...
</ProductPage> This combines the |
Beta Was this translation helpful? Give feedback.
-
I'm seeing the same thing on react-static v7.5.3. Works fine locally but produces duplicates after building. Submitted a bug report here: #1630 |
Beta Was this translation helpful? Give feedback.
-
When I try to use the
Head
from react-static it ends up with duplicate head meta tags -- and it uses the original head tags ..so how do i set it up so that different pages have different head meta when shared? isnt this like... one of ht emain reasons to have static lol
When running locally it works fine - i only have one set of meta tags... but once it is on the server i end up with duplicates.
The original meta tags used do not have the
data-react-helmet
prop ... so not sure what react-static is doing here... clearly theHead
used withDocument
an the head used when importing from react-static are completely different?Do we have to keep the meta for every page and render in the
Document
? This should be mentioned if so and is quite annoying since it specifically says you can just callHead
anywhere which doesn't appear to be true.Beta Was this translation helpful? Give feedback.
All reactions