I have my index.html page in react project as following:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Bucard | Digital Business Card</title>
<meta name="title" content="Bucard | Digital Business Card">
<meta name="description" content="Bucard - Description for bucard" />
<meta property="og:title" content="Bucard | Digital Business Card" />
<meta property="og:image" content="http://m.digital-card.co.il/zedka/152/images/icon.png" />
<meta property="og:description" content="Bucard - Description for bucard" />
<meta property="og:url" content="https://bucard.co.il/" />
</head>
<body>
<div id="root"></div>
</body>
</html>
And have my react-helmet section, which exist in component with a path of it self on the url:
<Helmet>
<title>{"Digital card of " + this.state.card.Name}</title>
<meta name="title" content={"Digital card of " + this.state.card.Name} />
<meta name="description" content="Description for the react-helmet section" />
<meta property="og:title" content={"Digital card of " + this.state.card.Name} />
<meta property="og:image" content="http://m.digital-card.co.il/friedman/249/images/icon.png" />
<meta property="og:description" content="Description for the react-helmet section" />
<meta property="og:url" content={"https://bucard.co.il/digitalCard/" + this.state.card.ShortID} />
</Helmet>
Now, the propblem here is that the only tag that replaces here is the <title> tag, but none of the <meta> tags are replaced.
I don't have server side rendering, I do have server side (node.js) and function that returns json of some values, that I render in my react application.
I search for almost 2 weeks but couldn't solve this yet, and this is very important to my project.
Tried also put data-react-helmet=true
in different situations, still not working though.
Can anyone please help me figure this out? Thanks a lot :)
I faced the same issue. And solved it as below.
In your server file (say server/index.js), add const helmet = Helmet.renderStatic() after ReactDOMServer.renderToString. My code looks like:
and add the following function. This is to update html content with helmet tags.
This may help you :)