6

On a HTML5 website, there is a single page, index.php . Its code contains other 5 pages.

An AJAX navigation is used, so the URL of other page looks like example.com/#!/page_Example.

I had tried to submit to Google many addresses of this kind using a XML sitemap, but Google indexes only the main page.

Also, I've made some 301 redirects from example.com/Example to example.com/#!/page_Example, and submitted them, but the main page is still the only one indexed.

How could I sumbit those URLs to Google?

3
  • 2
    A sitemap should be all you need. If those pages aren't indexed then your crawlable Ajax implementation is incorrect or Google has just chosen not to index those URLs.
    – John Conde
    Commented Feb 21, 2014 at 14:44
  • 1
    Look at developers.google.com/webmasters/ajax-crawling/docs/… Commented Feb 21, 2014 at 15:23
  • I'll go out on a limb and say that if you have a new HTML5 website, you'd be better served with using the HTML5 history API and using normal URLs. Use JS for navigation, change the URL in the browser, but serve static content on first load. Using the AJAX-crawling setup for a new site now seems a bit backward given the newer alternatives :-/ Commented Feb 25, 2014 at 22:00

2 Answers 2

3

According to Google, you should list your AJAX URLs in a sitemap exactly as you say you've done:

"4. Consider updating your Sitemap to list the new AJAX URLs

Crawlers use Sitemaps to complement their discovery crawl. Your Sitemap should include the version of your URLs that you'd prefer to have displayed in search results, so in most cases it would be http://example.com/ajax.html#!key=value."

At this point, I'll have to assume that the problem is somewhere else.

In particular, keep in mind that the method Google uses to fetch AJAX pages is not the same as how normal browsers do it, and that it requires extra server-side support (parsing the _escape_fragment_ query parameter and serving the appropriate server-side generated version of the AJAX content based on it). If your index.php is not set up to do that, Google will never even see you AJAX content, and thus cannot index it.

To start with, I'd suggest using the Fetch as Googlebot feature of the Google Webmaster Tools to see if Google can even load your AJAX content. If it cannot, follow the instructions here to set up your site so that it can.

2
  • And how could I do that? Pages are identified <ul> <li id="page_Example">...</li> <li id="page_Example2">...</li> ... </ul>. The only way I can access a page in browser is example.com/#!/page_Example. Google fetched it, but the whole source code is shown...
    – RazvanZ
    Commented Feb 23, 2014 at 12:20
  • ...and you're just toggling the visibility of the <li>s, rather than actually loading the content via AJAX? In that case, you could just add some code to your index.php so that, if it receives an _escaped_fragment_ parameter, it styles the matching <li> with display:block and all the others with display:none (or omits them entirely). Oh, and you probably should a) change your <title> to describe the page being shown, and b) use the <meta name="fragment" content="!"> trick for the main page. Commented Feb 23, 2014 at 12:38
1

Everything in a URL after the hash (#) is a fragment. This is data that is ONLY processed client-side and not even sent directly to the server or processed. There is no way to directly submit this to Google.

Google has procedures to help get around these limitations:

https://developers.google.com/webmasters/ajax-crawling/

1
  • "There is no way to directly submit this to Google" is kind of misleading, since, in fact, the instructions you've linked to say you should directly submit such URLs to Google in your sitemap. You just needs some extra server-side support to let Googlebot fetch them. Commented Feb 23, 2014 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.