Skip to content
Helpers to hide stuff you don't want to be indexed by search engines
Ruby JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.travis.yml
Gemfile
Gemfile.lock
MIT-LICENSE
README.rdoc
Rakefile
bad_bot.gemspec Initial commit, with all the juice. Sorry

README.rdoc

BadBot

This gem simply gives you the ability to avoid certain pieces of your view from being indexed by search bots.

Even if this is generally not recommended, there are situations that you really don't want parts to be indexed. Instead of loading all this stuff from a javascript, BadBot simply gives you an option for doing this instead:

<%= no_bot do %>
  stuff i dont wat to be indexed
<% end %>

in case of a search bot request, the content of the block won't be rendered.

Configuration

Include the gem in your gemfile: `gem 'bad_bot'`. And load it in a controller, for example `ApplicationController`:

class ApplicationController < ActionController::Base
  include BadBot::Detector
end

Usage

Once your controller is configured, you can call on you views/controller the `no_bot` and `is_bot?` methods:

Stories
<% no_bot do %>
  1 of 10 pages
<% end %>
...

Stories
<% unless is_bot? %>
  1 of 10 pages
<% end %>

Customization

By default it will only trigger for Google, Yahoo and Bing.

You can add new user-agents to the robots list by using the `BadBot::Bots.setup` method.

# some_initializer.rb
BadBot::Bots.instance.setup do |robots|
  robots << 'otherbot'
  robots << 'otherbot2'
end

Caution

How you will use this is entirely up to you. You can get punished by search engines if you make bad use of it. My intent on creating this was to remove some useless words that kept showing as the highest keywords at webmastertools.

Something went wrong with that request. Please try again.