LoginSignup
0
0

More than 3 years have passed since last update.

Railsでtitleタグの内容をページ毎に変えたい

Last updated at Posted at 2020-02-29

Ruby on Rails のViewファイルで、タイトルの文言を個別に変更するサンプルです。

サンプル

1.layout/application/htmlファイルのtitleタグ内を下記のように変える。

<%= content_for?(:title) ? yield(:title) : "デフォルトタイトル"%>

2.個別ページで、titleの内容を定義する。

<% content_for :title do %>
個別ページのタイトルの内容をココに書く。
<% end %>

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0