问题
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>
回答1:
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.
来源:https://stackoverflow.com/questions/50193960/react-helmet-facebook-open-graph