admin管理员组

文章数量:1194791

We use backbone heavily for rendering our pages. All the data is passed as json from the server and the html is created on the client with backbone and mustache. This poses a big problem for SEO. One way that I was planning to get around this was to detect if the request is from a bot and use something like HtmlUnit to render the page on the server and spit it out. Would love some alternate ideas. Also would like to know if there's a flaw in what I'm planning to do.

We use backbone heavily for rendering our pages. All the data is passed as json from the server and the html is created on the client with backbone and mustache. This poses a big problem for SEO. One way that I was planning to get around this was to detect if the request is from a bot and use something like HtmlUnit to render the page on the server and spit it out. Would love some alternate ideas. Also would like to know if there's a flaw in what I'm planning to do.

Share Improve this question asked May 29, 2012 at 16:35 Saurav ShahSaurav Shah 6813 gold badges8 silver badges16 bronze badges
Add a comment  | 

5 Answers 5

Reset to default 5

Build your site using Progressive Enhancement and Unobtrusive JavaScript.

When you do significant Ajax stuff, use the history API.

Then you have real URLs for everything and Google won't be a problem.

I don't necessarily like that the only option you have for answers are to redo everything to meet a broad best practice. There's good reason to consider doing things using an unobstrusive Javascript approach, but maybe there's a good reason you're doing this as a JS-required site. Let's pretend there is.

If you're doing a Backbone.js application with dynamically filled in client templates, the best way I could think of to do this is in the link below. Basically, it amounts to telling a headless browser to run through a set of navigation commands to view all your users/products/pages and save a static html file at every step for SEO reasons.

What's the least redundant way to make a site with JavaScript-generated HTML crawlable?

In a project I'm working on at the moment I'm attempting to cover all the bases.. Backbone driven client, pushstate uris, bookmarkable pages, and html fallback where possible. The approach I've taken is to use Mustache for the templates, break them up into nice little components for my backbone views and make them available in a raw format to the client. When a page is requested the templates can be processed on the server to produce a full page and backbone attaches to the elements it wants to control.

It's not a simple setup but so far I haven't hit any roadblocks and I haven't duplicated any templates. I've had to create a page wrapper template for each available url as Mustache doesn't do "wrappers" but I think I should be able to eliminate these with some extra coding on the server.

The plan is to be able to have some components as pure js where required by the interface and some rendered by the server and enhanced with js where desired..

if your are using node.js use rendr

Render your Backbone.js apps on the client and the server, using Node.js.

There's pros and cons to using the google ajax crawling scheme - I used it for a social networking site (http://beta.playup.com) with mixed results...

I wrote a gem to handle this transparently as rack middleware for ruby users (gem install google_ajax_crawler) (https://github.com/benkitzelman/google-ajax-crawler)

Read about it at http://thecodeabode.blogspot.com.au/2013/03/backbonejs-and-seo-google-ajax-crawling.html

The summary is that even though I successfully posted rendered dom snapshots to a requesting search engine, and I could see using webmaster tools that Google were crawling like 11,000 pages of the site, I found that Google were more prone to classify the apps various states (urls) as versions of the same page, and not as separate indexes. Try doing a search for beta.playup.com - only one index is listed even though the rendered content changes radically between urls )....

本文标签: javascriptSEO for a backbone js heavy pageStack Overflow