Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST/Ajax deep linking compatibility - Anchor tags vs query string

So I'm working on a web app, and I want to filter search results.

A nice restful implementation might look like this:

1. mysite.com/clothes/men/hats+scarfs

But lets say we want to ajax up the filtering, like the cool kids, and we want to retain deep linking, we might use the anchor tag and parse that with Javascript to show the correct listings:

2. mysite.com/clothes#/men/hats+scarfs

However, if someone clicks the first link with JS enabled, and then changes filters, we might get:

3. mysite.com/clothes/men/hats+scarfs#/women/shoes

Urk.

Similarly, if someone does not have JS enabled, and clicks link 2 - JS will not parse the options and the correct listings will not be shown.

Are Ajax deep links and non-Ajax links incompatible? It would seem so, as servers cannot parse the # part of a url, since it is not sent to the server.

like image 426
joeformd Avatar asked Nov 15 '22 14:11

joeformd


1 Answers

There's a monkeywrench being thrown into this issue by Google: A proposal for making Ajax crawlable. Google is including recommendations for url structure there that may give you ideas for your own application.

Here's the wrapup:

In summary, starting with a stateful URL such as http://example.com/dictionary.html#AJAX , it could be available to both crawlers and users as http://example.com/dictionary.html#!AJAX which could be crawled as http://example.com/dictionary.html?_escaped_fragment_=AJAX which in turn would be shown to users and accessed as http://example.com/dictionary.html#!AJAX

View Google's Presentation here (note: google docs presentation)

In general I think it's useful to simply turn off JavaScript and CSS entirely and browse your website and web application and see what ends up getting exposed. Once you get a sense of what's visible, you will understand what most search engines see and that in turn will show you what is and is not getting spidered.

like image 162
artlung Avatar answered Dec 07 '22 22:12

artlung