2

I have a very simple static HTML page with just one div. I have some static data defined in <head> and want jquery to iterate over this structure and append this inside the div startHere.

<body>
    <div id='startHere'></div>
    <script>
      $("#startHere").append(<function to generate html from the data>)
    </script>
  </body>

This works well in browsers and I see the content that I want to see. However when I try to use "Fetch as Google", I see an empty page with just the header.

The status of the request is shows as completed in the google tool.

Any idea why this page shows empty?

AbhinavD
  • 6,892
  • 5
  • 30
  • 40
  • What is expected result? – guest271314 Dec 14 '16 at 00:50
  • I'm fairly sure Google's crawler won't execute this type of javascript, so it renders the page as empty. – jonmrich Dec 14 '16 at 02:49
  • @guest271314 I want to see the same page as it renders in the browser (with by new HTML appended inside the div) – AbhinavD Dec 14 '16 at 03:36
  • @jonmrich Any ideas on how to get around this? Putting this logic inside `document.ready` doesn't help as well – AbhinavD Dec 14 '16 at 03:38
  • See https://webmasters.googleblog.com/2015/10/deprecating-our-ajax-crawling-scheme.html, https://webmasters.googleblog.com/2014/10/updating-our-technical-webmaster.html – guest271314 Dec 14 '16 at 04:07
  • Thanks @guest271314 for the link. However the links mentions that the page should be rendered like a modern browser. My robots.txt has no restrictions. `User-agent: * Disallow:` As mentioned, my page renders alright in the browser. – AbhinavD Dec 14 '16 at 04:26
  • Why do you use `Disallow`? See http://webmasters.stackexchange.com/questions/55799/is-my-whole-site-is-blocked-by-this-disallow. See also [Googlebot and empty CORS responses](http://stackoverflow.com/questions/40965697/googlebot-and-empty-cors-responses/41134627#41134627) – guest271314 Dec 14 '16 at 04:40
  • Not sure if it was clear in the text above but it was empty after `Disallow`. As per http://www.robotstxt.org/robotstxt.html, `To allow all robots complete access User-agent: * Disallow:` – AbhinavD Dec 14 '16 at 04:45
  • Why do you want to view the same page as it renders in browser at webmaster tools? Does the function call dynamically add links or images to the `document`? – guest271314 Dec 14 '16 at 04:54
  • Yes, this js function add text and images to the page. Pardon my ignorance but isn't the purpose of "Fetch as Google" is to see how the crawler sees your page and indexes it? – AbhinavD Dec 14 '16 at 05:14

0 Answers0