How to get 250k+ pages indexed by Google
Tags: webdev, tips, learning
Published: 2019-01-04 23:50:01

---
title: How to get 250k+ pages indexed by Google
published: true
canonical_url: https://davidkunnen.com/how-to-get-250k-pages-indexed-by-google
description: A guide for speeding up the crawling speed of your website from a few pages per minutes to many pages per second.
cover_image: https://thepracticaldev.s3.amazonaws.com/i/nvcq259ic8f670tllxyx.JPG
tags: #webdev, #tips, #learning
---

When creating [Devsnap](https://devsnap.io) I was pretty naive. I used create-react-app for my frontend and Go with GraphQL for my backend. A classic SPA with client side rendering. 

I knew for that kind of site I would have Google to index a lot of pages, but I wasn't worried, since I knew Google Bot is rendering JavaScript by now and would index it just fine

*Oh boy, was I wrong.*

At first, everything was fine. Google was indexing the pages bit by bit and I got the first organic traffic. 

![First indexing](https://thepracticaldev.s3.amazonaws.com/i/tbckeuwotch56sr6hv2v.png)

But somehow indexing was really slow. Google was only indexing ~2 pages per minute. I thought it would speed up after some time, but it wasn't, so I needed to do something, since my website relies on Google to index a lot of pages fast. 

# 1. Enter SSR

I started by implementing SSR, because I stumbled across some quote from a Googler, stating that client side rendered websites have to get indexed twice. The Google Bot first looks at the initial HTML and immediately follows all the links it can find. The second time, after it has sent everything to the renderer, which returns the final HTML. That is not only very costly for Google, but also slow. That's why I decided I wanted Google Bot to have all the links in the initial HTML. You can find more in-depth information about that topic in [this](https://www.christianoliveira.com/blog/en/seo-progressive-web-apps-pwa/) great article.


![Google Bot indexing zycle](https://thepracticaldev.s3.amazonaws.com/i/jiie4ygnge5jlc6nk96r.jpg)

I was doing that, by following [this](https://medium.freecodecamp.org/demystifying-reacts-server-side-render-de335d408fe4) fantastic guide. I thought it would take me days to implement SSR, but it actually only took a few hours and the result was very nice.

![Indexing with SSR](https://thepracticaldev.s3.amazonaws.com/i/zp8p56n8aid324v4m0k0.JPG)

Without SSR I was stuck at around 20k pages indexed, but now it was steadily growing to >100k.

*But it was still not fast enough*

Google was not indexing more pages, but it was still too slow. If I ever wanted to get those 250k pages indexed and new job postings discovered fast, I needed to do more. 

# 2. Enter dynamic Sitemap

With a site of that size, I figured I'd have to guide Google somehow. I couldn't just rely on Google to crawl everything bit by bit. That's why I created a small service in Go that would create a new Sitemap two times a day and upload it to my CDN.

Since sitemaps are limited to 50k pages, I had to split it up and focused on only the pages that had relevant content.

![Sitemap index](https://thepracticaldev.s3.amazonaws.com/i/i36qstybkd9byhw1bp5w.JPG)

After submitting it, Google instantly started to crawl faster. 

*But it was still not fast enough* 

I noticed the Google Bot was hitting my site faster, but it was still only 5-10 times per minute. *I don't really have an indexing comparison to #1 here, since I started implementing #3 just a day later.*

# 3. Enter removing JavaScript

I was thinking why it was still so slow. I mean, there are other websites out there with a lot of pages as well and they somehow managed too.

That's when I thought about the statement of #1. It is reasonable that Google only allocates a specific amount of resources to each website for indexing and my website was still very costly, because even though Google was seeing all the links in the initial HTML, it still had to send it to the renderer to make sure there wasn't anything to index left. It simply doesn't know everything was already in the initial HTML when there is still JavaScript left. 

So all I did was removing the JavaScript for Bots. *Don't use this snipped as is without knowing what it does. See JSON-LD further below.* 

```javascript
if(isBot(req)) {
    completeHtml = completeHtml.replace(/<script[^>]*>(?:(?!<\/script>)[^])*<\/script>/g, "")
} 
```

Immediately after deploying that change the Google Bot went crazy. **It was now crawling 5-10 pages - not per minute - per second.**

![Google Bot crawling speed](https://thepracticaldev.s3.amazonaws.com/i/77kz23tc3jz5n14boefk.JPG)

![Google Crawling stats]
(https://thepracticaldev.s3.amazonaws.com/i/fj531qkcyjhuk47r0adz.JPG)

![Google indexing result](https://thepracticaldev.s3.amazonaws.com/i/4hvq6vyju2l3lfwms0d3.JPG)

And this is the current result. Since I implemented the changes just recently, there are still a lot of pages that have been crawled, but haven't been indexed yet (grey bars). Nevertheless I'm more than happy with the result. 

After having Google index all the pages, the performance went up a lot as well. 

![Devsnap performance](https://thepracticaldev.s3.amazonaws.com/i/62qvba66iljh4e2h0dky.JPG)

####JSON-LD
Don't remove that! In my case JSON-LD is added after the snippet above. So be extra careful to not remove it.


# Conclusion

If you want to have Google index a big website, only feed it the final HTML and remove all the JavaScript (except for JSON-LD of course).