December 03 2008

New SEO friendly Taxonomy URLsby railsdog

Spree now features new SEO friendly URLs for browsing taxnomonies, this feature builds on top of the existing products SEO / permalink functionality to allow browsing products based on their location in a taxonomy. This is helpful for tracking how a user browsed to a particular product (ie. breadcrumbs), considering that products can have more that one taxon associated with it.

So now you can browse taxons using URLs like:


You can also view products with URLs like:


A new helper method called seo_url(taxon, product) is available in the ProductsHelper to give you the correct URL using a taxon and/or product. You can call the method two ways:

  1. For taxon’s you just need to pass a taxon object:

    seo_url(@tshirt-taxon) #=> /t/categories/clothing/shirts/t-shirts/

  2. For a combined taxon and product URL you pass in both objects:

    seo_url(@apache-taxon, @apache-tshirt) #=> /t/brands/apache/p/apache-baseball-jersey

    seo_url(@clothing-taxon, @apache-tshirt) #=> /t/categories/clothing/p/apache-baseball-jersey

All taxon related customer facing views have been updated to utilize these new URLs / methods.