Project

snipp

0.0
No commit activity in last 3 years
No release in over 3 years
Search Engine Optimization (SEO) helpers for Ruby on Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 3.2.11
 Project Readme

Snipp

Gem Version Coverage Status Build Status

Search Engine Optimization (SEO) helpers for Ruby on Rails

Supported

  • HTML meta tags
  • Rich snippets and structured data

Installation

Add the "snipp" to your application's Gemfile:

gem 'snipp'

And run bundle install command.

HTML Meta Tags

Call html_meta_tags in a view template.

<!DOCTYPE html>
<html>
<head>
  <meta charset='utf-8'>
  <%= html_meta_tags %>
  <%= stylesheet_link_tag :all %>
  <%= javascript_include_tag :defaults %>
  <%= csrf_meta_tag %>
  ...

Set content attribute values

The priority of setting values

  1. Call set_html_meta
  2. Use I18n dictionary (controller action scope)
  3. Use I18n dictionary (default scope)
  4. Set Snipp.config.html_meta_tags

Use helper

Call set_html_meta in a view.

set_html_meta({
  title: "Page Title",
  description: "Page Description",
  og: {
    title: "Title for Social Media"
  },
  link: {
    canonical: "https://github.com/yulii/snipp"
  }
}, {
  arg: "Option Values for I18n",
  page: params[:page]
})

User I18n dictionary files

for each controller action

I18n.t(:title, scope: [:views, params[:controller], params[:action], :meta])

default values

I18n.t(:title, scope: [:default, :meta])

For more information

Rich Snippets

Call item_tag like content_tag

<%= item_tag :div, scope: true, type: :review do %>
  <%= item_tag :span, 'Snipp', prop: :itemreviewd %>
  Reviewed by <%= item_tag :span, '@yulii', prop: :reviewer %> on
  <%= item_tag :time, 'April 1', prop: :dtreviewd, datetime: "2013-04-01" %>.
  <%= item_tag :span, 'Review summary...', prop: :summary %>
  <%= item_tag :span, 'Review description...', prop: :description %>
  Rating: <%= item_tag :span, '4.5', prop: :rating %>
<% end %>

This would output

<div itemscope itemtype="http://data-vocabulary.org/Review">
  <span itemprop="itemreviewed">Snipp</span>
  Reviewed by <span itemprop="reviewer">@yulii</span> on
  <time itemprop="dtreviewed" datetime="2013-04-01">April 1</time>.
  <span itemprop="summary">Review summary...</span>
  <span itemprop="description">Review description...</span>
  Rating: <span itemprop="rating">4.5</span>
</div>

Breadcrumbs

  1. Define naming routes. You can specify a name for any route using the :as option in Rails Application.
  2. Setup the Rails Application for Internationalization (i18n).
  3. Call breadcrumb method.
<%= breadcrumb [:index, :foods, :fruits] %>

This would output something like Top > Foods > Fruits, if you will set labels in your Rails.root/config/locales

en:
  views:
    breadcrumb:
      # Sample
      index: "Top"
      food: "Foods"
      food_fruit: "Fruits"

Link to root_path, food_path, food_fruit_path.

Change the separator

Use the :s or :separator option.

<%= breadcrumb [:index, :foods, :fruits], s: "/" %>

Use variables and Customize labels

<%= breadcrumb [:index, :foods, :fruits, { path: fruits_color_path('Red'), label: 'Red' }, { path: food_path(color: 'Red', name: 'Apple'), label: 'Apple' }], s: "/" %>

For more information, read erb files in app/view/snipp/

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

LICENSE

(The MIT License)

Copyright © 2013 yulii. See LICENSE.txt for further details.