#26 Meta Tags

Summary

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

Summary


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 = ', '
end


views/layouts/application.html.erb
  <%= 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' }
            ]
end


achmiral said over 2 years ago on Meta Tags :

Hi, 
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 over 2 years ago on Meta Tags :

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

achmiral said over 2 years ago on Meta Tags :

Cool, it's working now :D


Jayzen said over 2 years ago on Meta Tags :

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 about 2 years ago on Meta Tags :

Very good Tutorial :)

Login to Comment