16 Jun 2020

5 min read

React SEO: The Best Optimization Methods for React Websites

React SEO: The Best Optimization Methods for React Websites

In this article, you can find examples of how React can be compatible with SEO practices and how Google crawls these websites. You can follow these recommendations while changing your site's underlying structure or creating a new website.

Before moving on to SEO, the image below shows how Google crawls JavaScript and the stages a page goes through before it is indexed. Given the number of pages Google crawls daily, Googlebot can crawl the content completely and rank the page as long as it doesn't face any problems.

1647340421 react seo 3

Now that Googlebot is evergreen, it can crawl and index JavaScript websites better than its old Chrome 41 version. Before we start the optimization, here's a little background on React.

Below you can see an example of a website built with the React Framework;

1647340521 react seo 22

And below you can find 10 prominent websites built with React;

1647340437 react seo 6

The following image shows which JS frameworks market leaders use. React ranks first;

1647340512 react seo 20

Google can render React as well as other JavaScript frameworks. As we will discuss later in the article, the pages still need the basic SEO elements.

The graph below shows the number of clicks for a website using React in Search Console. If Googlebot couldn't crawl JS, the website's traffic wouldn't have increased and it would have had indexing problems. When React is introduced to Googlebot according to the rules, Google doesn't experience any problems at the rendering stage.

1647340505 react seo 18

When we examine the crawl statistics, we don't see anything that hindered or slowed down crawling in the last 90 days. According to the crawl data, Googlebot can also read React.

1647340501 react seo 17

Nowadays, among major search engines, Google supports React; other search engines do not completely support Angular or other JS frameworks.

1647340433 react seo 5

Image source.

React Router Usage

React is commonly used to build a SPA (single-page application). However, we can use the SPA model effectively as long as we properly specify certain rules and SEO elements on our pages.

It is crucial to open each page at a separate URL without a # (hashtag). As Google stated that it can't read hash-based URLs, it may not index URLs like these when they are created with React. That's why each URL should open a separate page.

Example of not recommended URL including hash: www.nameofwebsite.com/#zeo-react

We should use React Router in URLs. Below, you can find sample display;

1647340516 react seo 21

When creating content, we suggest avoiding a setTimeout process that displays it after a specified number of seconds. In such cases, Googlebot may not stay on the page long enough to read the content.

1647340446 react seo 8

Case in URL

Using different letter cases in URLs causes Google to consider them separate pages.

Example:

/zeo

/Zeo

Google will consider the two example URLs above separate pages. Using lowercase for all URLs will help you avoid duplicate pages.

"Ahref" Usage in Links

Links should be provided with "a href" because Googlebot can't read links created with onclick. Specifying links with a href allows Googlebot to find and visit other relevant pages from the page it is crawling.

1647340427 react seo 4

React Helmet

Metadata, one of the components of SEO, should appear in the source code even when React is used. Reusing the same description and title structures may not help with CTR and other SEO metrics;

1647340471 react seo 10

Image: Martin Splitt, React Developers

React Helmet helps in this issue. In the structure below, a sample code structure including metadata is shown;

1647340486 react seo 13

If the description element doesn't work or a page-specific description can't be provided automatically, you can fill the description with the first 160 characters of the page content.

1647340479 react seo 11

Other than metadata, structured data items should also be in the source code. (Product, organization schema etc.)

1647340416 react seo 2

As an example, you can see the Raw and Render versions of yolcu360.com below. Structured data appear in a protected form in both Raw and Rendered parts. There is no difference between them.

Raw;

1647340497 react seo 16

Rendered;

1647340411 react seo 1

When we test the page with Rich results test tool, GoogleBot can see the structured data on the page.

1647340442 react seo 7

You can show Google metadata in <head> and content elements in <body> by using Server-Side Rendering and Helmet together. Remember that the content should appear in the DOM. I also suggest taking a look at Dynamic Rendering.

Any errors or deficiencies in metadata may negatively affect all metrics in search results.

404 Error Code

If a page is defective, it should return a 404 error code. Remember to set up files such as route.js and server.js.

1647340493 react seo 15

A Reminder for Images

On-page images should definitely be indicated with "img src"; Googlebot announced that although it shows them in its tools without having any problems, it can't index them.

Proper use;

1647340490 react seo 14

Using CSS background and as such with React will lead to problems in indexing images.

Wrong use;

1647340509 react seo 19

React.Lazy

Using lazy load helps users explore the website faster and positively affects our page speed score in Google. For more details, you can check the page Using React with lazy load.

1647340451 react seo 9

You can use React-Snap for performance improvements in website speed. Sample use;

1647340482 react seo 12

Compared with other JS frameworks such as Angular or Vue, React can produce smaller files and avoid loading unnecessary code, which has a positive effect on page speed. For instance, you can split a JS file of 2 MB into 60-70 KB files and run separate processes.

We can say that the most important topics in React in terms of SEO are React Router, React-snap, and React Helmet.

When using JavaScript, remember that Google analyzes and crawls HTML websites better than JavaScript ones. However, as we've mentioned above, this doesn't mean it can't crawl JS-based websites. JavaScript websites simply require a little more care.

See you in other articles :)

Related service

Bring this question into your SEO plan

If this article points to a problem on your site, our SEO consultancy can help you decide what to check first and who should own the next step.
Explore SEO services
Samet Özsüleyman
Samet Özsüleyman