Alarm Grid will show you how to create canonical urls in Spree Commerce. This is only an example for products show. You must implement EVERYWHERE.
Last active
December 11, 2015 17:49
-
-
Save ehoch/4637369 to your computer and use it in GitHub Desktop.
Alarm Grid, a home security store, shows you how to set canonical urls in Spree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- if @canonical_url | |
= tag('link', :rel => 'canonical', :href => "http://" + Spree::Config[:site_url] + URI.parse(@canonical_url).path) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Deface::Override.new(:virtual_path => 'spree/layouts/spree_application', | |
:name => 'canonical_url', | |
:insert_bottom => "[data-hook='inside_head']", | |
:partial => 'shared/canonical_url') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Spree | |
ProductsController.class_eval do | |
before_filter :show_filter, :only => :show | |
def show_filter | |
@canonical_url = spree.product_path(:id => @product.permalink) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spree 2.0.4 now includes https://github.com/jumph4x/canonical-rails by default