Helps you manage page titles in your Rails application.
Tytus gives you a declarative manner in which to title your pages in order to improve overall design of your app and to increase findability of your pages in search ranks.
Add to your Gemfile:
And then execute:
Or install it yourself as:
$ gem install tytus
Update your locales file as in the following:
en: titles: site_name: Your site name goes here
In your controllers:
class ArticlesController < ApplicationController title 'A title for this particular controller' end
and this title will be inherited by all actions within controller. Alternatiely,
tytus will look for controller specific titles in your locales file. You can add them yourself under
titles key as in the following:
en: titles: plural_controller_name: Your site name goes here
However, if you need you can overwrite controller specific title on per action basis:
class ArticlesController < ApplicationController title 'A title for this particular controller' def show title 'A title for this particular action' end end
In your views:
<%- title 'A title for this particular view' %> or <h1><%= title 'A title for this particular view that renders also inside enclosed tag' %></h1>
and this will overwrite controller set titles.
Once you set your titles, in your layout call helper method
<head> <title><%= render_page_title %></title> </head>
:: separator is used to change this pass
separator hash parameter:
<head> <title><%= render_page_title :separator => ' | ' %></title> </head>
Questions or problems? Please post them on the issue tracker. You can contribute changes by forking the project and submitting a pull request. You can ensure the tests are passing by running
Copyright (c) 2011-2016 Piotr Murach. See LICENSE for further details.