SEO.js for Rails Build Status

Welcome to SEO.js for Rails! SEO.js makes your BackboneJS, AngularJS or EmberJS apps crawlable by Google to make them appear in search results. Integrating it to your Rails or Sinatra app is easy.

Installation

To get started add seojs to your Gemfile:

gem 'seojs'

Next you need an API token. To get it sign up at http://getseojs.com/. While you're there add your site in the dashboard so the snapshots can already be prepared.

Rails

To configure the API token for SEO.js create a new file in your project config/initializers/seojs.rb with the following content:

Seojs.token = "your_secret_api_token"

If you are running your app on Heroku you can also just set SEOJS_TOKEN environment variable:

heroku config:set SEOJS_TOKEN=your_secret_api_token

Sinatra

Add this to your config.ru (or other rackup file):

require 'seojs'
Seojs.token = "your_secret_api_token"
use Seojs::Middleware

That's it! Requests to your app containing the _escaped_fragment_ query parameter will now be forwarded to the SEO.js CDN where HTML snapshots of your pages are kept. To tell search engines to look for these snapshots you need to add the fragment meta tag to the head section of your application's layout (probably at app/views/layouts/application.html.erb):

<head>
  <meta name="fragment" content="!">
  ...
</head>

This method works both with HTML5 pushState URLs as well as Hashbang URLs (/some/action#!route)

Contributing to seojs

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

License

The MIT License (MIT)

Copyright (c) 2013 SEO.js. http://getseojs.com/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.