New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Graph og:site_name getting merged with title #119

Closed
brentdodell opened this Issue Jun 10, 2016 · 3 comments

Comments

4 participants
@brentdodell
Contributor

brentdodell commented Jun 10, 2016

I have the following:

site: 'Site Name',
title: 'Page Name',
reverse: true,
og: {
  site_name: :site,
  title: :title,
  description: :description,
  url: :canonical
}

Which results in the following HTML:

<title>Page Name | Site Name</title>
<meta content="My description" name="description">
<link href="http://mydomain.com/the/rest/of/the/url" rel="canonical">

<meta content="Page Name | Site Name" property="og:title">
<meta content="My description" property="og:description">
<meta content="http://mydomain.com/the/rest/of/the/url" property="og:url">

As far as the og: tags are concerned, they should be the following:

<meta content="Site Name" property="og:site_name">
<meta content="Page Name" property="og:title">
<meta content="My description" property="og:description">
<meta content="http://mydomain.com/the/rest/of/the/url" property="og:url">

I believe it is a bug that og:title is :title | :site. According to Open Graph's Basic tags, there should be separate og:site_name and og:title tags. Also, on that same page it mentions fb:app_id as one of the basic Open Graph tags. I believe this gem has issues with that as well (see issue #118).

Thanks for a great gem overall!

@detonatR

This comment has been minimized.

Show comment
Hide comment
@detonatR

detonatR Sep 8, 2016

having this issue too, did you manage to get a work around going?

detonatR commented Sep 8, 2016

having this issue too, did you manage to get a work around going?

@jakebellacera

This comment has been minimized.

Show comment
Hide comment
@jakebellacera

jakebellacera Jan 22, 2017

👍

any forks with this solved already?

jakebellacera commented Jan 22, 2017

👍

any forks with this solved already?

@kuboon

This comment has been minimized.

Show comment
Hide comment
@kuboon

kuboon Apr 11, 2017

I wrote monky patch for this issue. Add this to config/initializers/meta_tags.rb

module MetaTags
  class Renderer
    def render_title(tags)
      site       = meta_tags.extract(:site) || ''
      title      = meta_tags.extract_title || []
      separator  = meta_tags.extract_separator
      reverse    = meta_tags.extract(:reverse) === true

      normalized_meta_tags[:site]  = site
      normalized_meta_tags[:title] = TextNormalizer.normalize_title('', title, separator, reverse)

      site_title = TextNormalizer.normalize_title(site, title, separator, reverse)
      normalized_meta_tags[:site_title] = site_title
      tags << ContentTag.new(:title, content: site_title) if site_title.present?
    end
  end
end

normalized_meta_tags is a hash which is referred by symbol like :title.
Unfortunately extract_full_title removes title from hash and keeps it to nowhere, I didn't use the function.

kuboon commented Apr 11, 2017

I wrote monky patch for this issue. Add this to config/initializers/meta_tags.rb

module MetaTags
  class Renderer
    def render_title(tags)
      site       = meta_tags.extract(:site) || ''
      title      = meta_tags.extract_title || []
      separator  = meta_tags.extract_separator
      reverse    = meta_tags.extract(:reverse) === true

      normalized_meta_tags[:site]  = site
      normalized_meta_tags[:title] = TextNormalizer.normalize_title('', title, separator, reverse)

      site_title = TextNormalizer.normalize_title(site, title, separator, reverse)
      normalized_meta_tags[:site_title] = site_title
      tags << ContentTag.new(:title, content: site_title) if site_title.present?
    end
  end
end

normalized_meta_tags is a hash which is referred by symbol like :title.
Unfortunately extract_full_title removes title from hash and keeps it to nowhere, I didn't use the function.

@kpumuk kpumuk closed this in 0fd073f Aug 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment