The <title> tag

Currently, there is no dedicated solution for making page titles in
Ruby on Rails. However, there is lots of custom solutions out there. A
few examples:

The instance variable:

View:
<h1><%= @title = "Hello world" %></h1>

Layout:
<title>Awesome Site | <%= @title || "Your main source of awesomeness"
%></title>

The content_for helper:

<h1><% content_for :title, "Hello world" %></h1>

<title>Awesome Site | <%= yield :title || "Your main source of
awesomeness" %>

Besides this, there's also a few people that prefer to set the page
title in the controller. I wouldn't recommend that, though.

I recently posted a ticket on Lighthouse including a patch for Rails
that would allow you to use this syntax:

View:
<h1><%= title "Hello world" %></h1>

Layout:
<%= title(:site => "Awesome Site") %>

Which will output:

<title>Awesome Site - Hello World</title>

Two configuration options are available:

* reverse, reverses the order of page title and site name. Default is
false, site name first.
* separator, defines the separator of the page title and the site
name. Default is " - ".

More information on the patch here:
https://rails.lighthouseapp.com/projects/8994/tickets/2657-helper-for-generating-the-title-tag

Now, my question to you is: Which of the above solutions do you
prefer? If you have a completely different solution I would also like
to hear about it.

We have a solution that pushes strings to an array and laters joins with a delimiter and site name last. Unfortunately, this simple solution only fit half of our pages while other half were exceptions to this rule.

Because there are so many ways to do page titles I don’t think this is framework material.