I'm trying to load my react-helmet tags server-side so that these are injected into the static html file at build time. This would allow things like Facebook to take the source file directly and use the appropriate meta-tags.
After configuring my application with this, all I see in the server side static render output is:
<title data-react-helmet="true"></title>
Setup:
gatsby-config.js
module.exports = {
plugins: ['gatsby-plugin-react-helmet']
}
app.tsx
import Helmet from 'react-helmet';
const Head: React.FunctionComponent<Props> = () => (
<Helmet title="the title is big" >
<meta name="description" content="the content" />
</Helmet >
);
...
gatsby-ssr.js
const {Helmet} = require('react-helmet');
exports.onRenderBody = () => {
console.log(Helmet.renderStatic())
}
**Output**
<title data-react-helmet="true"></title>
Any ideas?
gatsby-ssr.js
so you shouldn't need to do it, it should work if you include yourHead
component to your page/template. How are you using yourHead
component? – Derek NguyenonRenderBody
should still work right?<Head />
is loaded into the a page template as a component. – Dylan PetiHelmet.renderStatic()
instead? That's what the gatsby plugin use – Derek Nguyengatsby develop
. – Dylan Peti