2

After reading up on getting content indexed in Google that is pulled into a page from an AJAX request, I have found that you can use pushState to change the URL and this will allow Google to find it.

My question is can you pushState as the current URL and this still work. So for example on the home page of the site, make your AJAX request then push state without parameters?

window.history.pushState('','','');
  • Why would you want to use push state if you don't need to change the URL? – Stephen Ostermiller Jun 7 at 10:20
  • To get AJAX content to index in Google ... – Paul Jun 7 at 10:44
1

You do not need to use pushState to get Google to index content that is loaded into the page via AJAX when the URL doesn't change. There is no need to use pushState at all in this instance.

To get Google to index a site that is fully powered by AJAX you need to:

  • Create separate URLs for each piece of content and use pushState to change the URL for human visitors as they navigate the site.
  • Make sure that when a visitor starts on a deep URL, the correct content is loaded.
  • Make sure that Googlebot can crawl all the content on the site by providing <a href links to all the URLs within the site. For human visitors, you can intercept clicks on these links, use AJAX to load the content, and use pushState to change the URL appropriately.

Using pushState is never required for Googlebot. pushState is required for human visitors so that they can:

  • Create bookmarks to sections of your site
  • Keep the AJAX experience even when they perform actions that would normally cause page loads like clicking on links.

There is no need to use pushState on the landing page before any clicks happen. In fact, doing so might prevent Googlebot from indexing your content correctly. You should only use pushState as visitors transition to different content. Googlebot will load and render AJAX calls that are required during the onload event of the page. There doesn't need to be (and shouldn't be) a pushState call to make that happen.

The only caveat is that it takes Googlebot longer to render pages than the initial static content Googlebot crawl. Googlebot may crawl your site and find that it requires AJAX. Your page will get put in the render queue. It may take Googlebot up to two months to come back and get the AJAX for that page and perform the rendering. Only once your page is rendered will Google index the content of a page that requires AJAX to load the content. Pages that require AJAX and rendering will be indexed more slowly and it will take Google longer to see updates to them.

Other search engines (Bing, Yandex, and Baidu) do not have bots as advanced as Googlebot. They probably won't be able to index pages that require JavaScript to load the content.

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.