iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 412 forks source link

using "#!" instead of just "#" hash frag route would support spiderable #1023

Open awwx opened 10 years ago

awwx commented 10 years ago

When using the appcache [edit: or older versions of IE], Iron Router converts a route like /one to /#/one.

Using #! would support the AJAX search engine crawling specification: https://developers.google.com/webmasters/ajax-crawling/docs/specification

See my PR for supporting AJAX search engine crawling in spiderable: https://github.com/meteor/meteor/pull/2938

I'd suggest converting /one to /#!one instead of /#!/one to keep the character count down, as the second / is unnecessary.

cmather commented 9 years ago

Oh interesting thanks @awwx. I'll look for your PR.

EDIT: Sorry, I see you meant a PR to mdg. I'm actually a bit confused here. I think Iron Router is only auto converting urls for IE. What about the appcache converts the url? Was this a PR that we pulled in previously?

awwx commented 9 years ago

@cmather Support for the appcache was added by @tmeasday in https://github.com/EventedMind/iron-location/commit/ea5085d461dad22fb482c5fc144e3d1fee2b6932

Whether as a result of that commit or some other change (I haven't looked at the code), iron-router is now converting urls for the appcache.

I presume iron-router has always used /#/path for IE, and that's why it's now doing it for the appcache.

My suggestion to use /#!path is actually just as valid for IE as it is for the appcache. Imagine someone is using IE and so gets a hash path, and then copy and pastes that URL into Facebook or whatever. Now Facebook or whoever attempts to fetch that URL to fill in the title and image and description and so on, but it can only do that with a /#!path so that it can use the AJAX search engine crawling specification.

So independent of whether you're using the appcache or not, if you are using hash paths (whether for IE or the appcache or something else), it's better to use /#!path paths because then they'll work with external services.

cmather commented 9 years ago

Thanks @awwx for the extra explanation. That makes sense. I don't see any reason why we shouldn't make this change. I'll come back to it shortly (have to switch to EM stuff for a bit). If someone has time to do a PR, or @awwx, I'm happy to add you to the projects. It's in iron:location.

cmather commented 9 years ago

https://github.com/EventedMind/iron-location/blob/master/lib/utils.js#L11. The two functions are there. I'll add this to next release tasks for myself but posting here in case someone wants to do it :).

cmather commented 9 years ago

@tmeasday do you have some time to make this change and update the tests?

tmeasday commented 9 years ago

I'll take a look.

txs commented 9 years ago

But in this way it kill the hash navigation for site.... Is there a solution to it?