Ajax SEO

Ajax Benefits

  • Single page Application
  • Send and Get response without a Browser Reload


  • Adding hash (#!) towards the end of the URL
  • Anything after #! is considered to change the page content.
  • Browser able to navigate between forward and backward using the hash (#)
  • Example : Twitter used #! before

Ajax Canonical Tag


<link rel="canonical" href="http://example.com/ajax.html#!foo=123" />

Don’t use

<link rel="canonical" href="http://example.com/ajax.html?_escaped_fragment_=foo=123" />.

XML Sitemap Creation

  • While creating a sitemap , make sure all the Ajax URL’s with #! are included

Where to use #! hashbang in Ajax page

Anything that user sees

  • All Hyperlinks
  • Sitemap
  • Redirects
  • …etc

Caution : Do not use : _escaped_fragment_ in the URL, where the user could see.

robots.txt to block a hash fragment

Disallow: /*_escaped_fragment_=DONOTCRAWL
  • Considering this is the fragment to block : #DONOTCRAWLthefragment

Using Headless Browser?

Example Browser : htmlunit

  • It needs to have a wait time for it to get the response so you could try waitForBackgroundJavaScript, waitForBackgroundJavaScriptStartingBefore
  • and there are few alternatives like NicelyResynchronizingAjaxController

Coding Alternatives

You could use pubshState() to change the URL without #! and it will look like a normal URL .

history.pushState([data], [title], [url]);