2012-06-09

A friend asked how to maintain high search rankings of a bunch of URLs that use Google’s #! AJAX URL convention. He cited Twitter as an example of a website doing it well. It’s true that Twitter uses #! in its URLs, and that Twitter pages rank highly in Google’s search results, but I notice that the search result URLs omit #! . Here’s how I think Twitter implements #! to maintain high search rankings:

The pages that rank highly omit #! : http://twitter.com/matthewlmcclure rather than http://twitter.com/#!/matthewlmcclure http://twitter.com/matthewlmcclure is a static HTML snapshot rather than a real time feed. The HTML snapshot includes the following so that requesting it in a JavaScript enabled browser will redirect to the corresponding #! URL that loads a real time feed: <script type="text/javascript"> //<![CDATA[ window.location.replace('/#!/matthewlmcclure'); //]]> </script> For every #! URL, there is a corresponding ?_escaped_fragment= URL like: https://twitter.com/?_escaped_fragment_=/matthewlmcclure The ?_escaped_fragment_= URL returns a 301 with Location: https://twitter.com/matthewlmcclure to close the loop and present the HTML snapshot to Google.