Module: Panda::CMS::SEOHelper
- Defined in:
- app/helpers/panda/cms/seo_helper.rb
Instance Method Summary collapse
-
#render_seo_meta_tags(resource) ⇒ String
Renders all SEO meta tags for a given page or post.
-
#seo_title(resource, separator: " · ", site_name: nil) ⇒ String
Renders just the page title with SEO optimization.
Instance Method Details
#render_seo_meta_tags(resource) ⇒ String
Renders all SEO meta tags for a given page or post
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 47 48 49 |
# File 'app/helpers/panda/cms/seo_helper.rb', line 13 def (resource) return "" if resource.blank? = [] # Basic SEO tags << tag.(name: "description", content: resource.effective_seo_description) if resource.effective_seo_description.present? << tag.(name: "keywords", content: resource.seo_keywords) if resource.seo_keywords.present? << tag.(name: "robots", content: resource.) << tag.link(rel: "canonical", href: canonical_url_for(resource)) # Open Graph tags << tag.(property: "og:title", content: resource.effective_og_title) << tag.(property: "og:description", content: resource.effective_og_description) if resource.effective_og_description.present? << tag.(property: "og:type", content: resource.og_type) << tag.(property: "og:url", content: canonical_url_for(resource)) # Open Graph image if resource.og_image.attached? og_image_url = url_for(resource.og_image.variant(:og_share)) << tag.(property: "og:image", content: og_image_url) << tag.(property: "og:image:width", content: "1200") << tag.(property: "og:image:height", content: "630") end # Twitter Card tags (with fallback to OG) << tag.(name: "twitter:card", content: "summary_large_image") << tag.(name: "twitter:title", content: resource.effective_og_title) << tag.(name: "twitter:description", content: resource.effective_og_description) if resource.effective_og_description.present? # Twitter image (same as OG) if resource.og_image.attached? << tag.(name: "twitter:image", content: url_for(resource.og_image.variant(:og_share))) end safe_join(, "\n") end |
#seo_title(resource, separator: " · ", site_name: nil) ⇒ String
Renders just the page title with SEO optimization
60 61 62 63 64 |
# File 'app/helpers/panda/cms/seo_helper.rb', line 60 def seo_title(resource, separator: " · ", site_name: nil) parts = [resource.effective_seo_title] parts << site_name if site_name.present? safe_join(parts, separator) end |