Skip to content

Instantly share code, notes, and snippets.

@cmdr-rohit-bang
Last active February 5, 2021 11:55
Show Gist options
  • Save cmdr-rohit-bang/8ac23ce3375ec4b9cf4d81c847752fb2 to your computer and use it in GitHub Desktop.
Save cmdr-rohit-bang/8ac23ce3375ec4b9cf4d81c847752fb2 to your computer and use it in GitHub Desktop.
Sub-Header and Meta Title

Install this gem in the project

gem 'metamagic'

In layouts/application.html.erb file

<%=metamagic site: "InitCoders", title: [:title, :site], keywords: [:keywords, "keyword 1", "keyword 2"], description: "", separator: " - " %>

Insert the following line at the very top of page of project (for eg. about_us.html.erb)

<%= render partial: 'layouts/partials/new_sub_header', locals: {page_title: 'About Us', page_sub_title: '']} %>

Now in layouts/partials/_new_sub_header.html.erb

<% meta title: "#{page_title}" %>
<h1><%=page_title%></h1>
<% unless page_sub_title.blank? %>
<p class="lead"><%=page_sub_title%></p>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment