Socket
Book a DemoInstallSign in
Socket

seo_rails_helpers

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seo_rails_helpers

0.2.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

SEO Rails Helpers

Gem Version Build Status

Collection of view helpers to improve search engine optimization of Ruby on Rails application.

Installation

SEO Rails Helpers requires Ruby version >=1.9.3 and Rails >= 3.2

Add this line to your Rails application's Gemfile:

gem 'seo_rails_helpers'

And then execute bundle command to install.

Usage

1. seo_page_title

This helper will produce SEO friendly page title. It assumes you are using either content_for or provide helper in your page view to store page title.

Include seo_page_title in the <head> section of your layout

ERB example:

<head>
  <%= seo_page_title %>
  <%# other elements %>
</head>

Haml example:

%head
  seo_page_title
  -# other elements

This will create HTML title element:

<title>Page Title | Base Title</title>

Exact format of title element will vary based on user-specific options.

seo_page_title options

NameDescriptionDefault
:page_titleIdentifier for stored page title. Specify symbol representing identifier in your provide or content_for method.:title
:separatorCharacter that separates :page_title and :base_title|
:base_titleBase title, like your brand or app name. In case :page_title is missing or empty the title will consist of :base_title only.Your Rails application name

example seo_page_title usage

provide(:page_title, 'Example Page')
seo_page_title(page_title: :page_title, 
               separator: '>', 
               base_title: 'Example Site')

Will produce following title element:

<title>Example Page &gt; Example Site</title>

2. seo_meta_description

This helper will create and insert meta element to specify description. Unlike seo_page_title, it produces meta description only when corresponding page explicitly sent it via either content_for or provide. Reason for such behavior - having any kind of default meta description is considered a bad SEO practice and may result in search engine ranking penalty.

Include seo_meta_description in the <head> section of your layout

ERB example:

<head>
  <%= seo_meta_description %>
  <%# other elements %>
</head>

Haml example:

%head
  seo_meta_description
  -# other elements

This will create HTML title element like:

<meta name="description" content="Example meta description" />

seo_meta_description options

NameDescriptionDefault
:descriptionIdentifier for stored meta description. Specify symbol representing identifier in your provide or content_for method.:description

example seo_meta_description usage

provide(:meta_description, 'Custom meta description')
seo_meta_description(description: :meta_description)

Will produce following title element:

<meta name="description" content="Custom meta description" />

Contributing

Fork the project and submit a pull request.

FAQs

Package last updated on 17 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.