How to optimize SEO for SPA using React-Helmet?
Asked Answered
D

1

11

My project is a single page application using react js. I have heard that Google can crawl javascript pages including react js single page applications, without the need of server side rendering (even though it's generally better for SEO).

However, when I used webmaster tool: fetch and render as google, both what google bots are seeing and what visitors to my page are seeing are blank. Even though I can add specific urls to google indexing, google only uses the title and description tag that I have put in my static index.html file, it doesn't get the nested react helmet component's title and description. Does anyone have experience in this? Appreciate it much!

Dorren answered 20/8, 2016 at 11:17 Comment(0)
C
4

To answer your question, ensure that you have polyfilled the necessary es6 features, google crawler's javascript feature can be quite limited, it does not have Array.find for example. You can read more about that here https://github.com/facebookincubator/create-react-app/issues/746#issue-179072109

As for tips for improving SEO, you can use these tips:

  1. You can prerender your pages on build time to static html by using react-snapshot https://www.npmjs.com/package/react-snapshot This works great if your app does not have many dynamic content.

  2. You can use pre rendering service like prerender.io / use static hosting with prerendering feature like netlify or roast.io. As for prerender.io, you can even host it yourself!

Cyn answered 24/5, 2017 at 11:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.