html_title
html_title
is a hook which allows the user to manually set the <title>
element with any string.
Typically, the <title>
element's text content is determined automatically, using the page_title
and application_title
, but this hook allows the user to override that default.
Here is an example of setting the html_title
with content_for
:
# app/views/weird_side_feature.html.erb
<% content_for :html_title, 'Double Secret Title' %>
If you wish to append your application_title
to your custom title, you can do so with:
content_for :html_title, "Double Secret Title | #{get_application_title}"
Note: This does not affect any elements in your HTML's <body>
, only in the <head>
.