Module: Spree::CanonicalUrlHelper
- Defined in:
- app/helpers/spree/canonical_url_helper.rb
Instance Method Summary collapse
-
#canonical_href(host = nil) ⇒ String
Returns the full canonical URL for the current request.
-
#canonical_path ⇒ String
Returns the canonical path for the current request (without query parameters).
-
#canonical_tag(host = nil) ⇒ ActiveSupport::SafeBuffer
Generates a canonical link tag for the current page.
Instance Method Details
#canonical_href(host = nil) ⇒ String
Returns the full canonical URL for the current request
15 16 17 18 |
# File 'app/helpers/spree/canonical_url_helper.rb', line 15 def canonical_href(host = nil) host ||= request.host "#{request.protocol}#{host}#{canonical_path}" end |
#canonical_path ⇒ String
Returns the canonical path for the current request (without query parameters)
23 24 25 |
# File 'app/helpers/spree/canonical_url_helper.rb', line 23 def canonical_path request.path.presence || '/' end |
#canonical_tag(host = nil) ⇒ ActiveSupport::SafeBuffer
Generates a canonical link tag for the current page
7 8 9 |
# File 'app/helpers/spree/canonical_url_helper.rb', line 7 def canonical_tag(host = nil) tag.link(href: canonical_href(host), rel: :canonical) end |