Meta tags help the browser and search engine to better interact with your website. They are important for SEO.

Some most common meta tags:

  • site title
  • page title
  • description
  • tags
  • author

Here’s how they can look in the <head> of an HMTL document:

<meta content="online education, course platform, video tutorials" name="keywords"/>
<meta content="Online Learning and Skill sharing platform" name="description"/>
<meta content="Yaroslav Shmarov" name="author"/>
<%= favicon_link_tag 'thumbnail.png' %>

1. Ruby on Rails: without a gem


  <%= content_for?(:title) ? yield(:title) : "SupeRails" %>

Now you can add a title tag on any page:


<% content_for :title do %>
  <%= controller_name.humanize %>
  <%= action_name.humanize %>
  <%= Inbox.count %>
<% end %>


<% content_for :title do %>
  <%= controller_name.humanize %>
  <%= %>
<% end %>


You might want to set up the app name dynamically based on config/application.rb.

Both below options work, but one is better

-- Rails.application.class.parent_name
++ Rails.application.class.module_parent_name

2. with gem meta-tags

However, for more complex behaviour and more meta_tag types (like description, tags) - better use gem meta-tags


bundle add meta-tags
rails generate meta_tags:install
  • add display_meta_tags to the layout
  • reverse: true - app name at the end like Inboxes | New | SupeRails


  <%= display_meta_tags site:,
                        description: 'Modern Ruby on Rails screencasts',
                        keywords: 'ruby, rails, ruby-on-rails', reverse: true %>
  • if you do not override the tags - defaults from the layout will be displayed


  def index
     set_meta_tags title: %w[Inboxes All]

  def show
    # set_meta_tags title: [, "Inboxes"]

    set_meta_tags title:,
                  description: @inbox.description,
                  keywords: 'seo, rails, ruby'

   def new
     set_meta_tags title: "#{action_name.capitalize} #{controller_name.singularize.capitalize}"
  • don’t forget that you can customize the settings in a config file


  config.title_limit = 200
  config.truncate_site_title_first = true