[Ruby on Rails] Quickly display the page title in the browser


スクリーンショット 2020-10-26 13.32.22.png

Development environment

ruby 2.5.7 Rails OS: macOS Catalina

Editing the base title


module ApplicationHelper
  def full_title(page_title = '')
    base_title = "app name"
    if page_title.empty?
      "#{ page_title } | #{ base_title }"

Edit title in head


  <title><%= full_title(yield(:title)) %></title>

Add title for each page

This time we will assume that you have a about page. The additional location is OK at the top.


<%= provide(:title, 'About the site')%>

When displaying the title using columns like Qiita article It is OK if you write as follows.


<%= 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

[Ruby on Rails] Quickly display the page title in the browser
Determine the current page with Ruby on Rails
[Ruby on Rails Tutorial] Error in the test in Chapter 3
Ruby on Rails Japanese-English support i18n
(Ruby on Rails6) Display of the database that got the id of the database
Delete all the contents of the list page [Ruby on Rails]
[Ruby on Rails] Confirmation page creation
How to display a graph in Ruby on Rails (LazyHighChart)
Check the root on the Rails browser
[Rails] How to change the page title of the browser for each page
I summarized the flow until implementing simple_calendar in Ruby on Rails.
Things to remember and concepts in the Ruby on Rails tutorial
part of the syntax of ruby ​​on rails
Ruby on Rails in Visual Studio Codespaces
Beginners create portfolio in Ruby on Rails
Pre-processing to display on the browser (compiler)
"" Application.js "is not present in the asset pipeline" error in Ruby on Rails
How to debug the processing in the Ruby on Rails model only on the console
Cloud IDE: Heroku couldn't be installed in the Ruby on Rails tutorial
[Ruby on Rails] How to display error messages
[Ruby on Rails] Until the introduction of RSpec
When the Ruby on Rails terminal rolls back
Recommendation of Service class in Ruby on Rails
Publish the app made with ruby on rails
Rails new in Ruby on Rails ~ Memorandum until deployment 2
Rails new in Ruby on Rails ~ Memorandum until deployment 1
Display "Hello World" in the browser using Java
Display "Hello World" in the browser using Java
(Ruby on Rails6) Creating data in a table
[Ruby on Rails] How to install Bootstrap in Rails
[Ruby on Rails] Ranking display (total, average value)
[Ruby on Rails] Individual display of error messages
[Ruby on Rails] Solving the addiction when setting crontab using whenever in EC2
How to resolve errors that occur in the "Ruby on Rails" integration test
Ruby on Rails Elementary
Ruby on Rails basics
Ruby On Rails Association
How to set the display time to Japan time in Rails
[Ruby on Rails] How to write enum in Japanese
Docker the development environment of Ruby on Rails project
[Ruby on Rails] How to change the column name
[Ruby on Rails] Posting score ranking function (whole display)
[Ruby On Rails] How to reset DB in Heroku
[Ruby / Rails] Set a unique (unique) value in the class
Display the list in setDetails on the screen with spring-security
[Ruby on Rails] Post image preview function in refile
Solve the N + 1 problem with Ruby on Rails: acts-as-taggable-on
(Ruby on Rails6) Reflecting the posted content from the form
[Rails] How to display an image in the view
Try using the query attribute of Ruby on Rails
[Ruby On Rails] Description that allows only specific users to transition to the edit page
[Ruby On Rails] In the nested state, the description in parentheses written after Prefix in the link_to method
[Ruby On Rails] How to use simple_format to display the entered text with line breaks
[Ruby On Rails / HTML] How to display the cursor (caret) at an appropriate place when displaying a web page
[Ruby on Rails] Only the user who posted can edit
Ruby on Rails 5 quick learning practice guide that can be used in the field Summary
Ruby on rails learning record -2020.10.03
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
Definitely useful! Debug code for development in Ruby on Rails
[Ruby on Rails] I want to get the URL of the image saved in Active Storage
Portfolio creation Ruby on Rails