What would be the best approach to a webshop in Craft, for solving the possibility of having products on more that on URL. Is there a best practice for one entry being accessible from more than one url? We use canonical for SEO.
Here is a quick summary of the current approach that works, but may be totally overkill :)
- Products are stored in a Channel.
- A product can be related to several entries in Structures > Product Categories.
- The product uri is for example /shop/category/subcategory/product - meaning that one product can have more than one location (url). The SEO issue with this is handled with canonical URLs (further down). The reason we want the product in several locations is that the store is for example selling a certain boot both as a "hiking boot" and a "hunting boot", so the context is different and it won't work as well going to domain.com/products/name without the category (keyword rich) structure in the url. Also having all product entries at the same base url like that (/products/name/) takes the user out of their current context in general (breadcrumb + section specific content/design) if they clicked the product at domain.com/shop/boots/hiking/high/.
- 3 routes are setup to send /shop/* (1-3 levels adding /* for each) to the ecommerce/_product template.
- Entry is not found when entering a product in this way, so if entry is not defined, it is set to be the one matching the last segment of the current URL (matched by slug).
- Now we're good to go to show the actual product entry.
- The issue of SEO (penalty for duplicate content) is handled with "canonical". I get all entries from Product Categories with a relation to the product (reversed relation), and defining the first one in that loop to be the main location (random - could be set as a relation on product level for the user to decide, but that requires "manual control" and may be hard for the client to relate to), and all other URLs showing the product in a different category that the main location will get in the header.
- In product listings we find the uri to each product again with reversed relations to all categories that has a relation to that product, and we prioritize the product category we are currently in. If the product is listed outside any of its product categories (like on a product page as a related product) it ends up with the base url from the last reversed related product category.
If you think this approach works well or if you have any other ideas.
I started out with native Categories for product categories. But the client is a brand selling their own product on their site, and each product category is a page with quite a bit more content than just the products, so I have a structure with an entry type for productCategory with several tabs (not possible for a Category).