3

I'm trying to implement ajax calls to load parts of a page only when a user gets to that part of the page and make sure at the same time that Google is able to read the content.

Here is what I have done:

  • created a link "view comments" on my page and adding #!module=comments to the url
  • on PHP side I capture the escaped_fragment and load static html
  • client side I have created a script that loads the static html when clicking on the link

It works fine. When I click on the link, I see the static content being loaded. If I access the URL directly (escaped_fragment) it also display the content correctly.

Now the SEO part with GoogleBot...

There is a possibility to simulate crawling from the Google Search Console. I tested the url with the script and I logged all visits on the static html page to see if Googlebot was getting there. The good news is that I see GoogleBot visiting the static html page.

How do I know if the static content of this page has been added to the main page? (and not seen as separate content) I'd like to transform all my pages with ajax loading if I'm not sure to do the right thing.

1

Hash bang URLs are deprecated. Googlebot no longer treats them any differently than any other URL. There is no reason to use hash bang URLs anymore. These days it is fine to use normal URLs rather than use special crawlable AJAX URLs.

Googlebot doesn't click on anything on the page. Anything that loads into the page when users click won't be indexed as part of the page. Googlebot does follow links on the page. If it can follow a link to the comments, it will see those comments as a separate page rather than part of the page.

You can get Google to index the text of the comments and still use AJAX. Rather than require users to click to read the comments, you can load the comments into the page every time the page loads. Googlebot now executes JavaScript that runs when the page loads and includes any loaded content as part of the page.

| improve this answer | |
  • Thanks! You are right, it's deprecated but still active, GoogleBot correctly translated the hash bang on my page to reach the comments. I also noticed that Googlebot clicks on the page because I could see hits from Googlebots on my comment page that is only accessible through a click. Anyway, I'll follow your suggestion, it's easier to implement. – Laurent Jul 17 at 10:06
  • 1
    Clicking is not the same as following links. Googlebot doesn't cilck. It finds the URL by examining the page source or the DOM and the schedules a crawl of it. Clicking runs JavaScript actions in the current page. Googlebot just doesn't do that. – Stephen Ostermiller Jul 17 at 12:19
  • ok, thanks. Does it associate the content behind this click to the current page? Following is one thing but if it considers the static html as a different page, it would defeat the purpose of using ajax. I'm wondering the same for onload triggers. – Laurent Jul 17 at 20:28
  • 1
    No, the content won't be indexed as part of the same page if the user has to click to it. You can use onload triggers with AJAX to get Google to index the content in the page. – Stephen Ostermiller Jul 17 at 21:31
  • 1
    Google it doesn't scroll the page either. – Stephen Ostermiller Jul 18 at 16:58

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.