Meta Tags

#26 Meta Tags
4/25/2016

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.
6
rails seo view

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: [email protected],
              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


10906059?v=3&s=64
achmiral said 3 months ago:

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.



635114?v=3&s=64
kobaltz said 3 months ago:

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

10906059?v=3&s=64
achmiral said 3 months ago:

Cool, it's working now :D


Login to Comment