kpumuk / meta-tags

Search Engine Optimization (SEO) for Ruby on Rails applications.
MIT License
2.73k stars 275 forks source link

Meta Description Not Showing Up #127

Closed LizBayardelle closed 8 years ago

LizBayardelle commented 8 years ago

I installed the meta-tags gem and copied my usage straight out of the documentation:

<% set_meta_tags description: 'Welcome to the Manly Art of BBQ, the online knowledge stockpile of all things manly. This includes, but is not limited to, how to cook great barbecue.',
                 keywords: 'knowledge, home, BBQ, barbecue, manly, art',
                 site: 'The Manly Art of BBQ' %>

Unfortunately, when I check for meta data using a site like this one it still doesn't see the meta data I inputted.

kpumuk commented 8 years ago

Do you have <%= display_meta_tags %> in your layout file? set_meta_tags is used on page templates to add meta tags defined in a layout. So,

  1. Add this to your layout:

    <%= display_meta_tags description: 'Welcome to the Manly Art of BBQ, the online knowledge     stockpile of all things manly. This includes, but is not limited to, how to cook great barbecue.',
                         keywords: 'knowledge, home, BBQ, barbecue, manly, art',
                         site: 'The Manly Art of BBQ' %>
  2. On your page files use <% set_meta_tags title: 'Another page' %> to set custom title, add tags, change description, etc.
cmalpeli commented 7 years ago

@LizBayardelle it's not too clear in the docs, but the order matters:

<% set_meta_tags description: 'Welcome to the Manly Art of BBQ, the online knowledge stockpile of all things manly. This includes, but is not limited to, how to cook great barbecue.',
                 keywords: 'knowledge, home, BBQ, barbecue, manly, art',
                 site: 'The Manly Art of BBQ' %>

  <%= display_meta_tags %>
kpumuk commented 7 years ago

If you use set_meta_tags in the layout, the values you passed will override the ones you set in your views. Instead, only display_meta_tags should be used in the layout:

<%=
  display_meta_tags(
    description: 'Welcome to the Manly Art of BBQ, the online knowledge stockpile of all things manly. This includes, but is not limited to, how to cook great barbecue.',
    keywords:    'knowledge, home, BBQ, barbecue, manly, art',
    site:        'The Manly Art of BBQ',
  )
%>