reactjsreact-helmet

React Helmet: Facebook Open Graph


So I've got react helmet working on my client-side app to re-render facebook og tags into the head depending on which page is active in the app.

however the facebook debugger and facebook itself don't pick any of this up. am i missing something ? is this only possible with server-side rendered pages?

i hope not as i'll have to learn node.js!

 <Helmet>
    <title>{props.title}</title>
    <meta property="og:url" content={ogUrl} />
    <meta property="og:type" content={props.type} />
    <meta property="og:title" content={props.title} />
    <meta property="og:description" content={props.desc} />
    <meta property="og:image" content={ogImg} />
 </Helmet>

Solution

  • Most search engines and crawlers use server's response directly, not allowing you to alter it with javascript. So yes, what you need is server-side rendering.

    Or, you can use tools like gatsbyjs, react-static. Basically, they render your components into HTML files beforehand.