ruby 2.5.7 Rails 5.2.4.3 OS: macOS Catalina
application_helper.rb
module ApplicationHelper
def full_title(page_title = '')
base_title = "app name"
if page_title.empty?
base_title
else
"#{ page_title } | #{ base_title }"
end
end
end
erb:application.html.erb
<head>
<title><%= full_title(yield(:title)) %></title>
</head>
This time we will assume that you have a about page. The additional location is OK at the top.
erb:app/views/homes/about.html.erb
<%= provide(:title, 'About the site')%>
When displaying the title using columns like Qiita article It is OK if you write as follows.
erb:app/views/homes/about.html.erb
<%= provide(:title, @genre.name)%>
By implementing these, it is possible to grasp the current position of the user, and It can be said that it is an indispensable function because it leads to improvement of the withdrawal rate of users.
Also, on twitter, technologies and ideas that are not uploaded to Qiita are also uploaded, so I would be grateful if you could follow me. Click here for details https://twitter.com/japwork
Recommended Posts