Gibson
Gibson

Reputation: 2085

Rails: How to use gem Meta-tags?

Has anyone tried to use meta-tags for Rails?

https://github.com/kpumuk/meta-tags

What does this mean?

Which syntax do I need to use?

Where to put it?

Little docs about it.

set_meta_tags :title => 'Member Login'
# <title>Some Page Title</title>
set_meta_tags :site => 'Site Title', :title => 'Member Login'
# <title>Site Title | Page Title</title>
set_meta_tags :site => 'Site Title', :title => 'Member Login', :reverse => true
# <title>Page Title | Site Title</title>

Upvotes: 3

Views: 5411

Answers (2)

Sibevin Wang
Sibevin Wang

Reputation: 4538

You may miss the MetaTags Usage section in meta-tags README.

Here is an example:

In layout:

<head>
  <%= display_meta_tags %>
  ...
</head>

In controller:

def show
  set_meta_tags title: "your title",
                keywords: "your keywords",
                description: "your description"
end

Upvotes: 12

OneChillDude
OneChillDude

Reputation: 8006

Put it in the head of the view. If your using HAML, that would look like

= set_meta_tags site: 'My Site'

and if your using ERB

<%= set_meta_tags site: 'My Site' %> 

Upvotes: 0

Related Questions