I have a legacy backbone.js app that I'm currently retrofitting to be properly crawlable by search engines. I've settled on using prerender.io's Node.js + Phantom.js system to serve static HTML renders of my javascript powered site to search engines. One of the requirements for using prerender.io however is that all hash URLs be converted to hashbang (so site.com/#gallery should be site.come/#!gallery). My site currently only uses hash for url routing. How can I switch this to a hashbang?
I suppose you have to change the url attributes of the anchor links pointing to #gallery to #!gallery and modify your router accordingly, e.g.
var app = app || {};
(function($){
Workspace = Backbone.Router.extend({
routes: {
'!gallery': 'gallery',
..
},
..
gallery: function() {
..
this.navigate('!/gallery', {trigger:true});
}
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With