#26 Meta Tags


Adding Meta Tags to your website is important for SEO ranking and content display. Learn how to easily add meta tags to your Ruby on Rails application.
rails seo view 4:39


Gemfile gem 'meta-tags'
config/initializers/meta_tags.rbMetaTags.configure do |c|
  c.title_limit        = 70
  c.description_limit  = 160
  c.keywords_limit     = 255
  c.keywords_separator = ', '

  <%= display_meta_tags %>
  <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>

app/controllers/articles_controller.rbdef show
  set_meta_tags title: @article.name,
            site: 'Cat Blog',
            reverse: true,
            description: @article.summary, 
            keywords: Faker::Lorem.words(4),
            twitter: {
              card: "summary",
              site: "@crazycatlady",
              title: "Crazy About Cats",
              description:  @article.summary,
              image: 'http://lorempixel.com/320/240/cats'
            og: {
              title:    "Cat Blog",
              description: @article.summary,
              type:     'website',
              url:      article_url(@article),
              image:    'http://lorempixel.com/320/240/cats'
            alternate: [
              { href: 'http://example.fr/base/url', hreflang: 'fr' },
              { href: 'http://example.com/feed.rss', type: 'application/rss+xml', title: 'RSS' }

achmiral said about 1 year ago:

This is a amazing usefull video tutorial :D. I have some issue when I click fullscreen icon, the video doesn't fill the entire screen monitor.

kobaltz PRO said about 1 year ago:

Thanks for pointing this out! I've pushed up a patch and this should be fixed now.

achmiral said about 1 year ago:

Cool, it's working now :D

Jayzen said 7 months ago:

i follow the right step in my project with rails 5.1, but it can't work.

the rails version in you video  is 4.2.6,  i can't figure out the problem, could you show me some tips! 

thanks for you awesome video, it helps me a lot!

Bishnu Basyal said 7 months ago:

Very good Tutorial :)

Login to Comment