I have a multi language website build with Gatsby, redux, redux-persist and Storyblok (CMS). When sharing our website in Slack I've noticed that no preview is available. I did some research and it looks that all the meta tags set via Helmet are present but they are not server rendered. You see the tags appearing when you inspect the website via the browser. As a result, when sharing the website, no preview text or picture is available (og meta tags, title & description) and I guess this also has a negative impact on general SEO as well.
The official Gatsby website is working fine though. After investigating the Gatsby repo I saw they are not using redux and custom html.js file. I'm wondering if the combination of redux and a custom html.js file can break the gatsby-plugin-react-helmet plugin?
I saw a lot of other people struggling with Helmet-related issues. Since SEO is an absolute key-stone of every website these days I think we have to improve both the plugin as well as documentation on how this plugin works and the current limitations. We've spent a lot of time creating this website and it's basically useless because of this problem, which is very hard to debug and information of how this plugin works in combination with Gatsby just doesn't exist.
Tags are set during build time via React Helmet.
Tags are inserted when the website is rendering in the browser. When inspecting the code in a browser you can see them appear.
System:
OS: macOS 10.14.3
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
Yarn: 1.3.2 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 71.0.3578.98
Firefox: 65.0
Safari: 12.0.3
npmPackages:
gatsby: ^2.0.91 => 2.0.91
gatsby-image: ^2.0.26 => 2.0.26
gatsby-plugin-eslint: ^2.0.3 => 2.0.3
gatsby-plugin-offline: ^2.0.21 => 2.0.21
gatsby-plugin-react-helmet: ^3.0.5 => 3.0.5
gatsby-plugin-react-svg: ^2.0.0 => 2.0.0
gatsby-plugin-sharp: ^2.0.17 => 2.0.17
gatsby-plugin-sitemap: ^2.0.4 => 2.0.4
gatsby-plugin-styled-components: ^3.0.4 => 3.0.4
gatsby-plugin-webpack-size: ^0.0.3 => 0.0.3
gatsby-source-filesystem: ^2.0.16 => 2.0.16
gatsby-source-storyblok: ^0.1.2 => 0.1.3
gatsby-transformer-json: ^2.1.7 => 2.1.7
gatsby-transformer-remark: ^2.2.0 => 2.2.0
gatsby-transformer-sharp: ^2.1.10 => 2.1.10
I've tried to reproduce using our using-redux example as a base - https://github.com/pieh/redux-helmet
And react-helmet definitely can consume data from redux store for static html render.

So I would assume there is something in your setup that cause SEO meta tags to not render into static html. But it's really hard to pinpoint what exactly without access to your project.
@pieh Thanks for your response. I've added you to the project on Gitlab so you can have a look. Meanwhile I've tried many things including removing html.js file, added the code of the plugin directly into gatsby-ssr.js but nothings works.
FYI: The tags are being set via Helmet only but on rendering (I guess) and not via SSR.
Update
I'm using Netlify as host and saw some people that have the same issue when hosting on Netlify. I'm uploading the project to an S3 bucket as we speak to make sure the hosting is not causing this.
I hope you can find some time to take a look and investigate this.
Got invite, but I don't seem to have access to actual code (have access to wiki / issues / members etc)
@pieh Now you should have access, my bad!
Thank for taking time for me :)
Ok, now I see it ;)
Hi @pieh, did you found some time to take a look at our code? I have no clue what could be wrong and am hoping you could point us in the right direction to solve this issue :)
Yesterday I did pull the code, and definitely could reproduce it. I couldn't find apparent reason yet. And I just made few notes for myself to when I have more time to investigate this more in depth:
There are 2
tags being added and not sure why - it appears only one instance of Helmet component is in the react component tree for pages.
Ok thanks @pieh. Luckily you are able to reproduce it. Regarding the title I've noticed that as well. Not sure how to continue on finding and resolving this issue.
Hopefully you find some time to help us out, thanks already for your time :)
@Jornve mind adding me too, I might take over from @pieh if he can't find the time.
Done @wardpeet :)
I don't know if it's related, but I just stumbled upon an issue with Helmet failing to render during SSR.
The symptom would be no helmet at all in build output, except for the <title> tag that would be empty.
(it's deceptive because when loading the page, client-side code kicks in and fills in the missing helmet data)
After a lot of fiddling around, I was able to make it work by adding this to my gatsby-node.js
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
externals: ['react-helmet']
});
};
I guess you can try and see whether it has any effect for you. If it does, we might be onto something.
[edit: however, that breaks develop mode]
@spectras Can you share your environment please? I've tried your solution in our project but it was no solution for our setup. Besides the dev mode not working, the build passes but you end up with errors in the bundles.
@wardpeet @pieh Did you find some time to investigate this further? After hours of searching and testing for a solution we saw some people having the same issues and they switched to Next.js in order to resolve the SEO problem with Helmet.
I prefer Gatsby over Next.js but if we cannot find a solution for this bug I'm afraid we have switch in order to solve our SEO problems.
It looks the problem is redux-persist https://github.com/rt2zz/redux-persist/issues/457
Perhaps you don't add that during SSR? You're not persisting anything in that environment so perhaps removing it will fix the problems it's causing.
@KyleAMathews Thanks for pointing this out. I'm building a version without redux-persist now. I'll keep you guys posted!
I can now confirm that redux-persist is causing this issue, it blocks SSR from working properly. After doing more research, one solution is to integrate the store after using react-helmet.
More info: https://github.com/gatsbyjs/gatsby/issues/10414
I suggest we add this limitation to the plugin documentations so people know this when they start using this plugin and don't have to restructure their repo later on!
Jornve> Doing the same thing in a second project yields the same result as yours: errors in bundles. But with helmet meta filled in, still. I don't understand why it works in the other project and I am no redux nor webpack expert.
I don't think my environment would be any helpful, over the months I have deviated a lot from defaults (custom plugins and build steps). I just figured I would share something that had an impact, in case it could help someone pinpoint the actual issue. Definitely nothing as solid as your investigation.
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
Thanks for being a part of the Gatsby community! 馃挭馃挏
Hey again!
It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
Thanks again for being part of the Gatsby community!
I just had this problem. Solved it this way:
Most helpful comment
I just had this problem. Solved it this way:
https://stackoverflow.com/a/62501513/7292383