SEO.js for Rails

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 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

License

The MIT License (MIT)

Copyright © 2013 SEO.js. 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.