Question

in backbone the hashbang was removed from the code with standard fallback to "#/path" which should be fine for crawling (see https://github.com/documentcloud/backbone/commit/10230e4d76e21f08a1dee1fe5d28994e2cf5f11d#commitcomment-477992)

but if a ie9 user wants to do a facebook share (copy paste url), i still need a _escaped_fragment_ handler, there i could do a canonical url or redirect to handle it in a clean way, but the "#!" fallback is still necessary, right ?

Was it helpful?

Solution 2

The answer is (if no one provides an alternative) no if you have these requirements its not a bad idea, see discussion with tkone

OTHER TIPS

The problem was when servers NEEDED the #! to determine where you were (a la Twitter/Gawker a few years ago). If you set your server correctly -- i.e. to always return your backbone app and (and start the router) for any URL within your app, it will handle correctly for all users.

IE8/9 users will see hashed urls. Sane browsers will display normal URLs. If a "sane" browser loads a hashed URL, the backbone router will know what to do. The same goes for IE8/9.

And as long as you're returning the correct view state for a given URL from the server, (i.e. pre-rendering on the server end), Google will have no problems just using your site like a normal website and indexing it merrily along.

The issue #! and _escaped_fragment_ were designed to handle really shouldn't matter much anymore.

EDIT

Example:

Lets say you have a Backbone app running on your server and it lives at http://myserver.com/myapp/. This is the base you pass into your Backbone.history object:

Backbone.history.start({pushState: true, root: '/myapp'});

This explains to the router that all the paths under /myapp/ are "owned' by the Backbone application. So long as ANY route requested that starts with /myapp/ returns your Backbone application, it will work, regardless of browser.

So, lets say your user is using the app and ends up with /myapp/awesome/thing/to/share. For an IE8/9 user, their URL will be /myapp#awesome/thing/to/share.

When the browser requests this from the server it only asks for /myapp. This returns your Backbone application and starts the history object/router. The router sees there is a hash fragment and says "oh give the user awesome/thing/to/share". This happens for ANY browser that requests this URL.

When an IE8/9 user requests /myapp/awesome/thing/to/share so long as your server returns that same Backbone app, the router will once again see that the path is /awesome/thing/to/share' and then automatically change the URL in IE8/9 to /myapp#awesome/thing/to/share.

The only place you need to do something tricky is if you want Google/Facebook to be able to scrape this page. Since they don't run javascript, the page will have to be sent from your server exactly as if Backbone had composed it in the browser -- or for Facebook, have the <og:*> tags available in the <head> section of the document.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top