So Meta
So Meta is a gem to simply manage meta content (title, description, canonical url, etc.) from within a Rails application
Installation
Add this line to your application's Gemfile:
gem 'so_meta'
And then execute:
$ bundle
Or install it yourself as:
$ gem install so_meta
Usage
So Meta uses the localization file to provide easy to modify SEO text content for page titles, descriptions and other text content for layouts and views.
en:
so_meta:
defaults:
title: "My Awesome New Rails Application"
description: "This application will be so viral, your startup
friends will be JEALOUS!"
pages:
about:
title: "About | My Awesome New Rails Application"
description: "Our company will blow your mind...like really."
pages_subresource:
about:
title: "About | My Awesome New Rails Application"
description: "Our company will blow your mind...like really."
contact:
title: "Contact %{name} | My Awesome New Rails Application"
<!-- views/layouts/application.html.erb -->
<!DOCTYPE html>
<html lang="en">
<head>
<title><%= so_meta(:title) %></title>
<meta name="description" content="<%= so_meta(:description) %>" />
<%= csrf_meta_tags %>
</head>
<body>
</body>
</html>
<!-- app/views/pages/contact.html.erb -->
<% so_meta_interpolation :title, name: "Brandon" %>
<h1>Contact</h1>
<p>Contact us now!</p>
Usage with scoping
<title><%= so_meta(:title, :phone) %></title>
en:
so_meta:
defaults:
title: "My Awesome New Rails Application"
description: "This application will be so viral, your startup
friends will be JEALOUS!"
pages:
about:
title: "About | My Awesome New Rails Application"
description: "Our company will blow your mind...like really."
phone:
title: "Specific title for phone"
matches
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request