Install the Rails middleware
To use SEO.js with a Rails app add the
seojs gem to your
$ bundle install
Configure your API key
Create a new file
config/initializers/seojs.rb in your project and set the API key.
YOUR_API_KEY with your real API key that you got when
Seojs.token = "YOUR_API_KEY"
Alternatively, if you prefer to keep credentials separate from code you can
SEOJS_TOKEN environment variable and leave the initializer empty.
If you’re using Sinatra or plain Rack instead of Rails you need to configure the
middleware in your
require 'seojs' Seojs.token = "your_secret_api_token" use Seojs::Middleware
Requests to your app containing the
_escaped_fragment_ query parameter will
now be forwarded to our CDN.
Enable AJAX crawling
To tell search engine crawlers that your site allows AJAX crawling you need to add the fragment meta tag to your HTML header.
<head> <meta name="fragment" content="!"> ... </head>
Use compatible URLs
Your URLs need to be in one of these formats:
/nice#!page- they are Hashbang URLs
/nice/page- they are HTML5 PushState URLs
Hashbang URLs are easier to implement and are compatible with older browsers, but many users find PushState URLs look more convenient.
Hash fragment URLs without the exclamation mark cannot be crawled:
/one#pageneeds to be changed to