Hashbang, you’re dead

Hashbang URLs are an ingenious way to make AJAX applications crawlable, proof that at least someone (and perhaps more than one person) in Google is clever, after all. The hashbang syntax is very concise, just a number sign (a hash, #) and an exclamation point (a bang, !), yet it provides a brilliant and sufficient notation that can help the web site and the crawler ‘communicate’ on how to index AJAX applications.

Of course, the web site designer has to respect the hashbang rules as set out by Google and design the web site with “hash fragments”, “escaped fragments”, “pretty URLs”, “ugly URLs” and “HTML snapshots” in mind.

Despite the benefits hashbang URLs brought with them, many analysts despised them. Some did not like the way they look, some the way they worked and some the problems that could arise by their improper implementation. Indeed, I will have to agree that improperly implemented, hashbangs can do a lot more harm than good.  The web site designer has to decide whether hashbang URLs will be beneficial to the site or not. The post “Breaking the Web with hash-bangs” provides insightful information and advice that web designers should be aware of.

To be fair, hashbang URLs are a successful attempt to make AJAX applications crawlable. But, apart from the fact that hashbang URLs can be dangerous sometimes, they also carry heavy ‘implementation baggage’, because web sites have to provide “ugly URLs” and “HTML snapshots”. Thus, additional work has to be made for the web site design that is not needed for the browsing experience itself.

Is there a better way? This is an interesting question, as long as the HTML standard remains the same (but we will not discuss this case here. The post “Breaking the Web with hash-bangs”, that I previously mentioned, has a lot of insightful input on this subject). But the HTML standard evolves, and now, with HTML 5’s session history and navigation, we can design web sites without having to resort to hashbangs for crawlability. The post “Degradable JavaScript Applications Using HTML5 pushState” describes this revolutionary concept. Also, for an easy to follow, yet thorough explanation of this concept, you can read “Manipulating the browser history”. So, yes, with HTML 5, there certainly is a better way.

So what do HTML 5’s session history and navigation have to do with hashbangs? Web designers had to use the hash (#) sign in the URLs, in order to manipulate the browser history. Everything after the hash is not sent to the web server as part of an HTTP request, though it is still used to denote a URL location. And since web designers had to resort to this hack, they also had to go the extra step to resort to the hashbang hack as well. Now all this functionality and more can be achieved with HTML 5’s session history and navigation. No hash tags are needed in the URLs. The site’s JavaScript manipulates the history and navigates it at will and without HTTP requests, but no anchors are used. The URLs remain “clean”, meaning they have no hash (and no hashbang) in them.

Bottom line: With HTML 5, the web applications can still use “back and forth” functionality as far as browser history is concerned, and, at the same time, avoid HTTP requests, while also avoiding the use of the hash symbol in the URLs, thus maintaining “clean” URLs for users and crawlers alike. And “clean” URLs, URLs without the hash symbol, are crawlable URLs.

So, are hashbangs dead yet? Well, if your site uses HTML 5, you can certainly do without them and you will be better off. But not all sites use HTML 5 or only HTML 5, so hashbangs may still be needed. Oh, well… I will keep the title of this post anyway. Let us call it “wishful thinking”.

Advertisements

About Dimitrios Kalemis

I am a systems engineer specializing in Microsoft products and technologies. I am also an author. Please visit my blog to see the blog posts I have written, the books I have written and the applications I have created. I definitely recommend my blog posts under the category "Management", all my books and all my applications. I believe that you will find them interesting and useful. I am in the process of writing more blog posts and books, so please visit my blog from time to time to see what I come up with next. I am also active on other sites; links to those you can find in the "About me" page of my blog.
This entry was posted in Web design. Bookmark the permalink.