<commit_before># Meta Rails

[![Gem Version](https://badge.fury.io/rb/meta-rails.svg)](https://badge.fury.io/rb/meta-rails)
[![Build Status](https://travis-ci.org/rubysamurai/meta-rails.svg)](https://travis-ci.org/rubysamurai/meta-rails)

Collection of view helpers to improve search engine optimization of Ruby on Rails application by including appropriate meta tags.

## Installation

Open your Rails application's `Gemfile` and add this line:

```ruby
gem 'meta-rails'
```

Save `Gemfile` and execute `bundle` command to install the gem.

### Title tag helper

While technically title element is not a meta tag, it is considered to be one of the most important information sources for search engines.

Optimal format for title, based on [Moz](https://moz.com/learn/seo/title-tag) and [Google Help](https://support.google.com/webmasters/answer/35624#3):

`<Page title> <Separator> <Brand Name>`

`meta-rails` has `title` helper to generate proper title element based on three properties, page title, separator, brand name: 

Property   | Default value 
-----------|---------------
Page title | `nil`         
Separator  | `|`           
Brand name | Rails app name

Page title value comes from assuming you are using either `content_for` or `provide` helper in the page view to store page's title, otherwise it will not be included and created title will consist only of brand name without page title and separator.

#### How to use `title` helper

```erb
# Utilize 'provide' or 'content for' to store page's title.
# mysite/app/views/static/contact.html.erb

<% provide(:title, 'Contact Us') %>
<%# other elements %>

# Include 'title' helper in the <head> section of your site:
# mysite/app/views/layout/application.html.erb

<head>
  <%= title %>
  <%# other elements %>
</head>
```

This code will create HTML `<title>` element:

```html
<title>Contact Us | Your Rails app name</title>
```

#### Options for `title` helper

Exact format of HTML `<title>` element can be modified by passing options hash to the helper:

Name         | Description                                   | Default
-------------|-----------------------------------------------|-----------
`:page_title`| Identifier for stored page's title.           | `:title`
`:separator` | Character between `:page_title` and `:brand`  | `|`
`:brand`     | Your brand or site name.                      | Rails app name
`:reverse`   | Switch position of `:page_title` and `:brand` | `false`

Example of `title` helper usage with options:

```erb
# mysite/app/views/static/contact.html.erb

<% provide(:title, 'Contact Us') %>
<%# other elements %>

# mysite/app/views/layout/application.html.erb

<head>
  <%= title(page_title: :page_keyword,
            separator: '-',
            brand: 'MyBrand',
            reverse: true) %>
  <%# other elements %>
</head>
```

This example code will create HTML `<title>` element:

```html
<title>MyBrand - Contact Us</title>
```

## Contributing

Anyone is welcome to contribute to Meta Rails. Please [raise an issue](https://github.com/rubysamurai/meta-rails/issues), fork the project, make changes to your forked repository and submit a pull request.

## License

`meta-rails` © <NAME>, 2015. Released under the [MIT](https://github.com/rubysamurai/meta-rails/blob/master/LICENSE.txt) license.<commit_msg>Clarify example [ci skip]<commit_after># Meta Rails

[![Gem Version](https://badge.fury.io/rb/meta-rails.svg)](https://badge.fury.io/rb/meta-rails)
[![Build Status](https://travis-ci.org/rubysamurai/meta-rails.svg)](https://travis-ci.org/rubysamurai/meta-rails)

Collection of view helpers to improve search engine optimization of Ruby on Rails application by including appropriate meta tags.

## Installation

Open your Rails application's `Gemfile` and add this line:

```ruby
gem 'meta-rails'
```

Save `Gemfile` and execute `bundle` command to install the gem.

### Title tag helper

While technically title element is not a meta tag, it is considered to be one of the most important information sources for search engines.

Optimal format for title, based on [Moz](https://moz.com/learn/seo/title-tag) and [Google Help](https://support.google.com/webmasters/answer/35624#3):

`<Page title> <Separator> <Brand Name>`

`meta-rails` has `title` helper to generate proper title element based on three properties, page title, separator, brand name: 

Property   | Default value 
-----------|---------------
Page title | `nil`         
Separator  | `|`           
Brand name | Rails app name

Page title value comes from assuming you are using either `content_for` or `provide` helper in the page view to store page's title, otherwise it will not be included and created title will consist only of brand name without page title and separator.

#### How to use `title` helper

```erb
# Utilize 'provide' or 'content for' to store page's title.
# mysite/app/views/static/contact.html.erb

<% provide(:title, 'Contact Us') %>
<%# other elements %>

# Include 'title' helper in the <head> section of your site:
# mysite/app/views/layout/application.html.erb

<head>
  <%= title %>
  <%# other elements %>
</head>
```

This code will create HTML `<title>` element:

```html
<title>Contact Us | Your Rails app name</title>
```

#### Options for `title` helper

Exact format of HTML `<title>` element can be modified by passing options hash to the helper:

Name         | Description                                   | Default
-------------|-----------------------------------------------|-----------
`:page_title`| Identifier for stored page's title.           | `:title`
`:separator` | Character between `:page_title` and `:brand`  | `|`
`:brand`     | Your brand or site name.                      | Rails app name
`:reverse`   | Switch position of `:page_title` and `:brand` | `false`

Example of `title` helper usage with options:

```erb
# mysite/app/views/static/contact.html.erb

<% provide(:page_keyword, 'Big Sale') %>
<%# other elements %>

# mysite/app/views/layout/application.html.erb

<head>
  <%= title(page_title: :page_keyword,
            separator: '-',
            brand: 'MyBrand',
            reverse: true) %>
  <%# other elements %>
</head>
```

This example code will create HTML `<title>` element:

```html
<title>MyBrand - Big Sale</title>
```

## Contributing

Anyone is welcome to contribute to Meta Rails. Please [raise an issue](https://github.com/rubysamurai/meta-rails/issues), fork the project, make changes to your forked repository and submit a pull request.

## License

`meta-rails` © <NAME>, 2015. Released under the [MIT](https://github.com/rubysamurai/meta-rails/blob/master/LICENSE.txt) license.
{'fraction_non_alphanumeric': 0.1546562358958929, 'fraction_numerical': 0.0030088761847449977, 'mean_word_length': 3.2560819462227912, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '998695', 'n_tokens_mistral': 2068, 'n_tokens_neox': 1905, 'n_words': 686}