<commit_before># MetaTags: a gem to make your Rails application SEO-friendly

[![Travis-CI build status](https://secure.travis-ci.org/kpumuk/meta-tags.svg)](http://travis-ci.org/kpumuk/meta-tags)
[![Gem Version](https://badge.fury.io/rb/meta-tags.svg)](https://badge.fury.io/rb/meta-tags)
[![Code Climate](https://codeclimate.com/github/kpumuk/meta-tags/badges/gpa.svg)](https://codeclimate.com/github/kpumuk/meta-tags)
[![Test Coverage](https://codeclimate.com/github/kpumuk/meta-tags/badges/coverage.svg)](https://codeclimate.com/github/kpumuk/meta-tags/coverage)

Search Engine Optimization (SEO) plugin for Ruby on Rails applications.

## Ruby on Rails

MetaTags master branch now fully supports Rails 3.2+, and is tested against all
major Rails releases up to 5.0.1.

Ruby versions older than 2.0.0 are no longer officially supported.

## Installation

Add the "meta-tags" gem to your `Gemfile`.

```ruby
gem 'meta-tags'
```

And run `bundle install` command.

## Configuration

MetaTags follows best-practices for meta tags. Although default limits for
truncation have recommended values, you can change them to reflect your own
preferences. In order to do that, you can create an initializer
`config/initializers/meta_tags.rb`, with following code:

```ruby
MetaTags.configure do |c|
  c.title_limit        = 70
  c.description_limit  = 160
  c.keywords_limit     = 255
  c.keywords_separator = ', '
end
```

## SEO Basics and MetaTags

### Titles

Page titles are very important for Search engines. The titles in the
browser are displayed in the title bar. The search engines would look at
the this title bar to determine what the page is all about.

```ruby
set_meta_tags title: 'Member Login'
# <title>Some Page Title</title>
set_meta_tags site: 'Site Title', title: 'Member Login'
# <title>Site Title | Page Title</title>
set_meta_tags site: 'Site Title', title: 'Member Login', reverse: true
# <title>Page Title | Site Title</title>
```

Recommended title tag length: up to <b>70 characters</b>, <b>10 words</b>.

### Description

Description tags are called meta tags as they are not displayed by the
browsers as that of titles. But these descriptions may be displayed by
some search engines. They are used to describe the contents of a page in
2 or 3 sentences.

```ruby
set_meta_tags description: "All text about keywords, other keywords"
# <meta name="description" content="All text about keywords, other keywords" />
```

Recommended description tag length: up to <b>160 characters</b>.

### Keywords

Meta keywords tag are used to place your keywords that you think a
surfer would search in Search engines. Repeating keywords unnecessarily
would be considered spam and you may get permanently banned from SERP's<commit_msg>README: Correct the example output<commit_after># MetaTags: a gem to make your Rails application SEO-friendly

[![Travis-CI build status](https://secure.travis-ci.org/kpumuk/meta-tags.svg)](http://travis-ci.org/kpumuk/meta-tags)
[![Gem Version](https://badge.fury.io/rb/meta-tags.svg)](https://badge.fury.io/rb/meta-tags)
[![Code Climate](https://codeclimate.com/github/kpumuk/meta-tags/badges/gpa.svg)](https://codeclimate.com/github/kpumuk/meta-tags)
[![Test Coverage](https://codeclimate.com/github/kpumuk/meta-tags/badges/coverage.svg)](https://codeclimate.com/github/kpumuk/meta-tags/coverage)

Search Engine Optimization (SEO) plugin for Ruby on Rails applications.

## Ruby on Rails

MetaTags master branch now fully supports Rails 3.2+, and is tested against all
major Rails releases up to 5.0.1.

Ruby versions older than 2.0.0 are no longer officially supported.

## Installation

Add the "meta-tags" gem to your `Gemfile`.

```ruby
gem 'meta-tags'
```

And run `bundle install` command.

## Configuration

MetaTags follows best-practices for meta tags. Although default limits for
truncation have recommended values, you can change them to reflect your own
preferences. In order to do that, you can create an initializer
`config/initializers/meta_tags.rb`, with following code:

```ruby
MetaTags.configure do |c|
  c.title_limit        = 70
  c.description_limit  = 160
  c.keywords_limit     = 255
  c.keywords_separator = ', '
end
```

## SEO Basics and MetaTags

### Titles

Page titles are very important for Search engines. The titles in the
browser are displayed in the title bar. The search engines would look at
the this title bar to determine what the page is all about.

```ruby
set_meta_tags title: 'Member Login'
# <title>Member Login</title>
set_meta_tags site: 'Site Title', title: 'Member Login'
# <title>Site Title | Member Login</title>
set_meta_tags site: 'Site Title', title: 'Member Login', reverse: true
# <title>Member Login | Site Title</title>
```

Recommended title tag length: up to <b>70 characters</b>, <b>10 words</b>.

### Description

Description tags are called meta tags as they are not displayed by the
browsers as that of titles. But these descriptions may be displayed by
some search engines. They are used to describe the contents of a page in
2 or 3 sentences.

```ruby
set_meta_tags description: "All text about keywords, other keywords"
# <meta name="description" content="All text about keywords, other keywords" />
```

Recommended description tag length: up to <b>160 characters</b>.

### Keywords

Meta keywords tag are used to place your keywords that you think a
surfer would search in Search engines. Repeating keywords unnecessarily
would be considered spam and you may get permanently banned from SERP's
{'fraction_non_alphanumeric': 0.10555959302325581, 'fraction_numerical': 0.009084302325581396, 'mean_word_length': 4.61734693877551, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '388755', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1617, 'n_words': 632}