Module: Helios::Seo::TagsHelper
- Defined in:
- app/helpers/helios/seo/tags_helper.rb
Overview
The single source of truth for a content page's
machine layer. Renders title, description, canonical, robots, Open Graph, Twitter card, and exactly one JSON-LD block. Supersedes any ad-hoc content_for :head markup so social/OG tags are never emitted twice.Instance Method Summary collapse
-
#helios_seo_tags(resource, config: Helios::Seo.configuration, title: true) ⇒ Object
Usage (in a layout or view
): <%= helios_seo_tags(@post) %>.
Instance Method Details
#helios_seo_tags(resource, config: Helios::Seo.configuration, title: true) ⇒ Object
Usage (in a layout or view
):<%= helios_seo_tags(@post) %>
Pass title: false when the surrounding layout already renders its own
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/helpers/helios/seo/tags_helper.rb', line 13 def (resource, config: Helios::Seo.configuration, title: true) presenter = ResourcePresenter.new(resource, config, view: self) = [] # Core << tag.title(presenter.document_title) if title << ("description", presenter.description) << ("keywords", presenter.keywords) << tag.link(rel: "canonical", href: presenter.canonical_url) << ("robots", presenter.robots) # Open Graph << ("og:title", presenter.headline) << ("og:type", "article") << ("og:url", presenter.canonical_url) << ("og:description", presenter.description) << ("og:image", presenter.image_url) << ("og:site_name", config.site_name) << ("article:published_time", presenter.published_time) << ("article:modified_time", presenter.modified_time) # Twitter / X << ("twitter:card", "summary_large_image") << ("twitter:title", presenter.headline) << ("twitter:description", presenter.description) << ("twitter:image", presenter.image_url) << ("twitter:site", config.twitter_site) << ("twitter:creator", config.twitter_creator) # JSON-LD (exactly one block) << json_ld_tag(resource, config) safe_join(.compact, "\n") end |