Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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> 
like image 935
Timmy Lee Avatar asked May 05 '18 20:05

Timmy Lee


1 Answers

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.

like image 65
Gokhan Sari Avatar answered Oct 02 '22 12:10

Gokhan Sari