1

I have a react built app. And Google is only indexing the main page "/". I don't understand how React and SEO work together. Do you have any tips? Any help would be appreciated.

I have tried the Google Fetch and Render tool, and it only fetches the main page.

Link Example:

  goToPhoto(pageName) {
    const {history} = this.props;
    history.push(`/photo/${pageName}`);
  }

  <a onClick={() => this.props.goToPhoto(photo.pageName)}>`${photo.title}`}</a>
  • What happens if you type the URLs of other pages into your browser bar? – Stephen Ostermiller Jan 12 '18 at 21:51
  • It goes to the expected page @StephenOstermiller – MMrj Jan 13 '18 at 15:44
  • 1
    Consider testing it with javascript disabled. You might run into non-functional buttons. Also, its hard for me to give a solid answer because you're asking us to focus more on a specific framework and it might require specific code to perform the core HTML functions. As for google indexing, try to make quality pages that people want and make sure you don't use the robots noindex directive and make sure your server isn't blocking google from accessing pages. – Mike Jan 14 '18 at 23:48
  • 1
    "it only fetches the main page" - what about for URLs of your other pages? Or is that what you are saying; they don't return anything in the Google Fetch and Render tool? – MrWhite Jan 15 '18 at 11:25
2
+50

The old answer used to be use a product like Prerender.io in order to get Google to crawl it. Google has started processing Javascript and although a product that pre-renders a page for the engine makes life easier it's not the only answer.

A common problem I've encountered is that if your app takes too long to load, if your AJAX calls or event loops take more than 2-3 seconds, Google will not wait. It will go with what it's got, links included. The solution to this will depend very much on your architecture but I would suggest looking at speed, caching, CDN and other factors that could make it difficult for Google to load in under 5 seconds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.