3.3.4 Eliminating duplication with layouts

Now that we’ve replaced the variable part of the page titles with ERb,
each of our pages looks something like this:

<% provide(:title, 'Foo') %>
<!DOCTYPE html>
<html>
  <head>
    <title>Ruby on Rails Tutorial Sample App | <%= yield(:title)
%></title>
  </head>
  <body>
      Contents
  </body>
</html>

In other words, all our pages are identical in structure, including the
contents of the title tag, with the sole exception of the material
inside the body tag.

In order to factor out this common structure, Rails comes with a special
layout file called application.html.erb, which we renamed in Section
3.3.1 and which we’ll now restore:

$ mv foobar app/views/layouts/application.html.erb

To get the layout to work, we have to replace the default title with the
Embedded Ruby from the examples above:

<title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>