Hi everyone. Is there any way to customise the URL...
# support
g
Hi everyone. Is there any way to customise the URL structure? Currently, it appears as if: Taxonomies/categories:
<http://domain.com/t/[taxonomie]/[taxon_1]/[taxon_2]|domain.com/t/[taxonomie]/[taxon_1]/[taxon_2]>
.. Example:
<http://mydomain.com/t/dog/food/dry|mydomain.com/t/dog/food/dry>
Product landing page:
domain/products/[product_slug]?taxon_id=[id]
Example:
<http://mydomain.com/products/eden-80-20-original-cuisine|mydomain.com/products/eden-80-20-original-cuisine>
My clients' previous store has super SEO and user-friendly URLs. They rank well. Ideally, I'd like to keep the same URL structure, but slight deviations are okay, as we will 301 redirect them if required! Change 1) - When it comes to Taxonomies / Category URLs, is there a way to get rid of the "`/t/`" in the URL, which I suppose stands for "taxonomies" and is a namespaced/scoped so as not to break the routing. But if I bear that in mind and make sure taxonomies are unique and do not interfere with any other namespace, scope and URL. For example: instead of "`mydomain.com*/t/*dog/food/dry`", we prefer "`mydomain.com/dog/food/dry`" Change 2) - Each product has only one (1!) taxonomy attached to it. So a product can not have multiple taxonomies/taxons assigned. Therefore we would like to remain SEO friendly and have the taxons as part of the product landing page URL. For example: instead of "`mydomain.com/products/eden-80-20-original-cuisine`", we would like the URL to be "`mydomain.com/dog/food/dry/eden-80-20-original-cuisine`" Does anyone know if I can do that, and if so, how? Any help is appreciated! Thank you!
e
For the taxon routes if you want to get rid of the
/t/
you need to add a catch all with a constraint, something like:
Copy code
get '/*taxon', to: 'spree/products#index', constraints: ->(req) { 
  Spree::Taxon.exists?(permalink: req.path.slice(1..))
}
and then ini the products controller you need to filter products by the taxon permalink you have in
params[:taxon]
🎉 1
👌 1
g
Hi @elia! Thank you, that is very helpful!
Sorry for not replying any earlier.
e
No problem, glad it helped!