kpumuk / meta-tags

Search Engine Optimization (SEO) for Ruby on Rails applications.
MIT License
2.73k stars 275 forks source link

Add custom attribute for meta tag #192

Open kvandake opened 5 years ago

kvandake commented 5 years ago

When I add Helmet to my React Application I have duplicates of the description tag. To solve a duplicate, I need to add attribute data-react-helmet to the description tag.

For example

<meta name="description" content="some description" data-react-helmet="true">

Can I add this attribute?

CongCong-1228 commented 2 years ago

Did you solve this problem, I don't think it's different from deleting

EdgeCaseLord commented 2 weeks ago

Adding custom attributes to the description tag and others, as in config.title_tag_attributes = { id: 'page-title' } would enable them to get updates via Turbo streams, too.

bhtabor commented 1 week ago

Faced a similar issue with the refresh tag. Had to add data-turbo-track="reload" to avoid turbo interference with meta refresh. Previous page was refreshing even after navigating away. Here is a patch for that. Usage would be set_meta_tags refresh: { interval: 60, data: { turbo_track: 'reload' } }

module MetaTags
  module RendererPatch
    protected

    def render_refresh(tags)
      refresh = meta_tags.extract(:refresh)

      if refresh.present?
        interval = refresh[:interval].to_s
        data = refresh[:data] || {}

        tags << Tag.new(:meta, { "http-equiv" => "refresh", content: interval, data: })
      end
    end
  end
end

MetaTags::Renderer.prepend(MetaTags::RendererPatch)