Coder Social home page Coder Social logo

kpumuk / meta-tags Goto Github PK

View Code? Open in Web Editor NEW
2.7K 2.7K 274.0 849 KB

Search Engine Optimization (SEO) for Ruby on Rails applications.

License: MIT License

Ruby 99.89% Shell 0.11%
meta-tags opengraph opengraph-tags rails ruby search-engine-optimization seo seo-meta seotools twitter-cards webmasters

meta-tags's Introduction

πŸ‡ΊπŸ‡¦ Hi, I'm Dmytro (aka kpumuk)

Mastodon Twitter GitHub

meta-tags's People

Contributors

5minpause avatar ahmozkya avatar andrewgarner avatar andrewmartin avatar artplan1 avatar beenashetty avatar benhaan avatar benjaminkim avatar cookiescrumbs avatar dependabot[bot] avatar dlackty avatar eric-guo avatar fmalamitsas avatar guillaumebriday avatar gururuby avatar juanjorivera avatar kpumuk avatar matthewcallis avatar nagi avatar naveda89 avatar rafallo avatar reckerswartz avatar salzig avatar schiza avatar silva96 avatar snicky avatar srecnig avatar sue445 avatar wakairo avatar zmokizmoghi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meta-tags's Issues

Meta tags using i18n locale files

Has it been considered to add ability to add meta tags using i18n locale files?

E.g. in a namespace like:

en:
  meta_tags:
   [controller]:
     [action]:
       title: My locale title
       description: Foo baa

etc. ?

Alternate links output empty

I tried using the alternate links syntax specified in the second example (referenced below) but the output is empty.

set_meta_tags alternate: [
    { href: 'http://example.fr/base/url', hreflang: 'fr' },
    { href: 'http://example.com/feed.rss', type: 'application/rss+xml', title: 'RSS' },
    { href: 'http://m.example.com/page-1', media: 'only screen and (max-width: 640px)'},
  ]

Nested namespaces generate the wrong markup

The following code:

set_meta_tags :title => venue.name, :og => {
  url: request.fullpath,
  type: venue.type.name,
  title: venue.name,
  place: {
    location: {
      latitude: venue.latitude.to_i,
      longitude: venue.longitude.to_i
    }
  }
}

Generates:

<meta content="/venues/19-sunt-eos" property="og:url" />
<meta content="Convention Center" property="og:type" />
<meta content="Sunt Eos" property="og:title" />
<meta content="{:location=&gt;{:latitude=&gt;49, :longitude=&gt;-122}}" property="og:place" />

I will try to rollback to previous versions and see if the problem still exists. Current version: 1.2.6

Microdata is not supported

Now we can't generate meta tag

<meta itemprop="description" content="description content" /> 

Will be this gem updated in the future?

Default Open Graph metatags are not merged but overridden.

So you got in your layout:

<%= display_meta_tags :site => 'Site Name',
                      :open_graph => { :site_name => 'Site Name' } %>

And in some action:

<%- set_meta_tags :title => 'Page Title',
                  :open_graph  => { :title => 'Page Title' } %>

This results in:

<title>Site Name | Page Title</title>
<meta content="Page Title" property="og:title" />

That is we lost this one:

<meta content="Site Name" property="og:site_name" />

Not working with Rails 3

I am perhaps missing something, but I can't seem to get the proper output using this plugin with rails 3. I'm including the gem using the Bundler gemfile, and the gem is properly installed after running bundle install. I also get a "true" when running require 'meta_tags' from irb.

It seems though that something is missing because the set_meta_tags method throws an error whenever I attempt to use it, and the the <% title 'Document Title' %> tag in the erb file doesn't throw an error, but doesn't output anything.

Seems like I'm missing something. Is my using bundler to manage this plugin incorrect? It seems to me that the installation instructions on the readme apply only to rails 2.

Thanks in advance

Add support for Dublin Core meta tags

What about add support for the Dublin Core meta tags?

I would suggest to add official support from "meta-tags" gem, but I also would suggest that someone update the README.MD talking about DC and how to implement Dublin Core meta tags on a given website (like the mini-tutorial for OG tags and Twitter Cards).

What do you think about that?

"can't modify frozen object"

got this error in normalize_title(title) line 211 and following in view_helper.rb.
to fix it, add
title = title.dup if title.frozen?
as first line in the function.

Use <single_space> as separator

I trying to figure out, but seems that is impossible to have a (single space) as title separator. Like:

Site name Title name

If you use :separator => false, you got joint words:

Site nameTitle name

If you use :separator => '', you got double spaces:

Site name  Title name

if you use :separator => ' ', you got triple spaces:

Site name   Title name

If you don't use :separator at all, you got a pipe:

Site name | Title name

So I presume there's no way to use _single space_, or am I missing something?

Formatting?

It would be really nice if this gem produced the meta output with the name/property first and then the content. It does the job but the code is really hard to read in source.

Favicon support with :icon

Would an :icon option be of value to this gem? If so, I'm willing to submit a pull-request for it.


Defaults to "image/x-icon":

set_meta_tags icon: "/favicon.ico"
<link href="/favicon.ico" rel="icon" type="image/x-icon">

Supporting different mime types:

set_meta_tags icon: { "image/png" => "/images/icon.png" }
<link href="/images/icon.png" rel="icon" type="image/png">

I can not see meta title?

How can I add meta title?

I can see the title

<title> My Site | Title </title>

but I can not see in my head:

<meta content=" Title " name="title">

Thank you very much!

Not woking in production Environment

I am getting this error in the production environment, but this is working perfectly fine in development.

ActionView::Template::Error (undefined method `display_meta_tags' for #<#<Class:0x0000000219c470>:0x00000002037eb8>):
    14:     %meta{:content => "yes", :name => "apple-touch-fullscreen"}
    15:     %meta{:content => "default", :name => "apple-mobile-web-app-status-bar-style"}
    16:
    17:     = display_meta_tags @meta
    18:
    19:     / BEGIN Vendor CSS
    20:     = stylesheet_link_tag 'dashboard/application', media: 'all', 'data-turbolinks-track' => true
  app/views/layouts/dashboard.html.haml:17:in `_app_views_layouts_dashboard_html_haml__3819368442363062716_16686580'

Using rel="alternate" hreflang="x"

is it possible to add this tag for multilanguage websites?

<link rel="alternate" hreflang="de" href="http://example.com/de/" />

Thank you!

Canonical undefined when trying to set in the view

I am trying to set the canonical URL in the view of a project and it always comes back undefined. I can successfully set it in the controller, but I want to be able to override it in the view occasionally.

This is what I am putting in the view..

<% canonical "http://google.com" %>

And I get this error..

undefined method `canonical' for #<#Class:0x007ff6b7b2b550:0x007ff6b52716f0>

I'm using..
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
Rails 4.2.3
Mac OS X 10.10.4

I am able to set the other tags in the view.

Any advice?

Option to hide the global site title

Is there an option to not show the default site title in the title tag ? (in order to only show the value passed to set_meta_tags :title)

I know it's possible to reverse it with :reverse => true, but I didn't find any option to completely remove it.

I want certain pages to only show their title and not the site name.

Thanks !

Support Charset

Love this gem, but it would be great if it could also support "user-defined" meta tags.

Would love to have the charset meta tag defined with it:

meta charset="utf-8"

Dunno if this is already possible?

supporting og:image source AND width, height, and type

Hi there,

I ❀️ your gem!

I'm running into trouble trying to specify and image source and the additional (albeit optional) width, height and type properties e.g. from Facebook's Example:

I'm trying to recreate this:

<meta property="og:image" content="http://example.com/lamb-full.jpg">
<meta property="og:image:type" content="image/jpeg">
<meta property="og:image:width" content="3523">
<meta property="og:image:height" content="2372">

Following your spec, I create this (you can see where it will fail):

set_meta_tags :og => {
  :image    => "http://example.com/lamb-full.jpg",
  :image    => {
    :type  => "'image/jpeg"
    :width  => "3523",
    :height => "2372"
  }
}

... and I get this when I call display_meta_tags (the URL is missing)

<meta property="og:image:type" content="image/jpeg">
<meta property="og:image:width" content="3523">
<meta property="og:image:height" content="2372">

The reason why is obvious. Just wondering if you had any workarounds?

Cheers,
Lee 🍻

HTML attribute strings should be escaped

The following code:

set_meta_tags og: {description: 'Testing "double quotes".'}

Will output HTML below:

<meta content="Testing "double quotes"." property="og:description" />

Double quotes are not escaped, breaking the HTML markup.

Specs failing with actionpack 4.2.0

A lot of the specs rely on matching tag strings, eg <meta content="this is a test" name="testing" />

This is rendered using ActionView::Base#tag. In 4.2 the attribute order switches so the following does not match:

<meta content="this is a test" name="testing" />
<meta name="testing" content="this is a test" />

49 spec failures with latest Rails :-(

To reproduce:

Do fresh clone and bundle install or on existing bundle update actionpack then

bundle exec rspec spec

Ability to append page number to description

I have a description e.g.

<% set_meta_tags description: "This is a description" %>

I'd like to append a page number when the user advances beyond page 1. However unlike content_for, setting with set_meta_tags replaces this value rather than appending.

Is there a solution in this gem for this, or would that be a new feature?

not work in Rails 3.1

Below is my trace:

➜  web git:(master) βœ— rails s
/Users/marshluca/Code/Work/web/vendor/bundle/ruby/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb:66: uninitialized constant ActionView::Helpers::AssetTagHelper::AssetPaths::Mutex (NameError)
    from /Users/marshluca/Code/Work/web/vendor/bundle/ruby/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/helpers/asset_tag_helper.rb:3:in `require'
    from /Users/marshluca/Code/Work/web/vendor/bundle/ruby/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/helpers/asset_tag_helper.rb:3
    from /Users/marshluca/Code/Work/web/vendor/bundle/ruby/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/helpers.rb:38
    from /Users/marshluca/Code/Work/web/vendor/bundle/ruby/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/base.rb:134
    from /Users/marshluca/Code/Work/web/vendor/bundle/ruby/1.8/gems/meta-tags-1.2.4/lib/meta_tags.rb:11
    from /Users/marshluca/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
    from /Users/marshluca/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
    from /Users/marshluca/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
    from /Users/marshluca/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
    from /Users/marshluca/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
    from /Users/marshluca/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
    from /Users/marshluca/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
    from /Users/marshluca/Code/Work/web/config/application.rb:7
    from /Users/marshluca/Code/Work/web/vendor/bundle/ruby/1.8/gems/railties-3.1.0.rc4/lib/rails/commands.rb:52:in `require'
    from /Users/marshluca/Code/Work/web/vendor/bundle/ruby/1.8/gems/railties-3.1.0.rc4/lib/rails/commands.rb:52
    from /Users/marshluca/Code/Work/web/vendor/bundle/ruby/1.8/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:in `tap'
    from /Users/marshluca/Code/Work/web/vendor/bundle/ruby/1.8/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49
    from script/rails:6:in `require'
    from script/rails:6

Change title format

Is there a way to change title from

SITE_NAME | PAGE_NAME

To:

PAGE_NAME. SITE_NAME

support Open Graph structured properties for images

Open graph supports "structured properties" for images, videos, audio, etc.

Currently, this gem allows us to set them for a video through the [:og][:video] hash. But [:og][:image] takes a string or an array for the image urls, from which we get one or several og:image tags.

It would be great to have an option [:og][:images] that takes an array of hashes, where each hash can specify the :url, :width, :height, :type, and :secure_url for the image. (Note the <meta name="og:image:url" ...> tag is equivalent to og:image.)

Specifying the width, height, and type is a convenience for people who are having trouble getting FB/Linkedin/etc to properly analyze their image. But being able to pass the secure_url is essential for sites whose image canonical protocol is https. And as we've seen just this month, Google is giving you points for moving towards the future of the web by using HTTPS.

While working on this, it would probably be good to look towards similar options for other Open Graph objects that can be listed multiple times and have individual properties.

In README, how to install with bundler

In README file, you could state that the gem may be installed in the Rails 3 Gemfile (with bundler) with the line:

gem 'meta-tags', :require => 'meta_tags'

and then:

bundle install

Thanks!
./stefan

Add support for alternate links (RSS, Atom)

I need to add tags like:

<link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.example.net/feed.rss" />

to a blog index page. Unfortunately, this GEM isn't able to do that as far as i can see.

disable site name

Hi!
Can I disable site name?
So I have:

on layout:
<%= display_meta_tags %>

on my page:
<% set_meta_tags(:title => @category.meta_title,
:keywords => @category.meta_keywords,
:description => @category.meta_description) %>

What in result:

<title> | sometitle</title>

What I need:

<title>sometitle</title>

How can I make that?

Error in displaying title

I have used below code in gem file:

gem 'meta-tags', :require => 'meta_tags'

and in layout

<%= set_meta_tags :site => 'Site Title', :title => 'Member Login' %>

I received the below output

{"site"=>"Site Title", "title"=>"Member Login"}

in wrong format unable to type here: html encode format is displayed there

I need <title>Hello </title> unable to type correct bracket here

Facebook OG meta-tags?

This would be a cool new additional feature. Add Facebook Open Graph met tags converting a web page into on open graph object.

Thanks for consideration,

Steve

Turbolinks

It's possible to use this gem with turbolinks?

undefined method 'configure' for MetaTags::Module

I get the above undefined method error when trying to configure via an initializer on Rails 4.1.13. Using meta-tags version 2.0.0. Also crops up when manually calling MetaTags.configure in the console, and configure doesn't show up in the list when running MetaTags.methods via pry.

Gem Naming Issue

The reason that you have to explicitly state require 'meta_tags' is because the naming on this gem is not following the convention that Rubygems and Bundler do.

Rubygems β€œName Your Gem Guide”

There is currently not a gem registered under meta_tags in Rubygems, so it should be trivial to do a rename and release under the new heading without disrupting any existing installs. This would then allow people to simply enter gem 'meta_tags' in their gemfile and it would be loaded automatically.

tag.rb already taken

Hi, I see meta-tags uses tag.rb filename which is in use by my tagging modell already. What can be done?

CONTENT="NOINDEX, FOLLOW"

Its really nice abilyti to create this tag:

with 2 attributes noindex and follow, this tell to the bot to no index the page, but follow the links present, its common use in the pages with pagination.

Can't Load HTML Sanitizer

I get this strange error when running autotest:

ActionView::Template::Error:
       cannot load such file -- html/sanitizer

When I go to the line its:

<%= display_meta_tags blah %>

Anyone know how to fix this?

Ability to accept any meta tag

It would be nice to accept any possible meta tag. For example, I need an author tag -- instead of adding support for just the author tag, why not add support to accept any meta tag?

pedrofs has an implementation of this: pedrofs@2f411bf

Problem with ampersand

set_meta_tags = title: "&" outputs <title>&amp;&amp;</title>
Should output <title>&amp;</title>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.