Forum
Perch Shop - URL Advice
Hi Drew,
I'm building a Perch Shop and for SEO reasons what to include the full category path in the product page route, for example
/products/timber/cladding/**my-product**
The problem is, sometimes a category has a subcategory, eg:
/products/timber/cladding/softwood
This renders the route wrong for some product pages, and category pages. What would you suggest as an implementation here?
Thanks, Ryan.
What have you tried? I think this should work.
That worked fantastically, you're a star Drew! To get a product's URL, is this the best approach:
/<perch:categories id="category" set="products" label="Category"><perch:if exists="perch_item_last"><perch:category id="catPath" /></perch:if></perch:categories><perch:shop id="slug" type="slug" />
, in it's own template then reused where I need the link?Cheers!
Ah it's so close to working!
Two URL's:
/products/timber/decking/q-deck/
/products/stoves/esse/esse-100
They clash when I set
products/[slug/slug/slug:catPath]
The problem is technically the routes are the same, could either be a category page, or a product page.
Take the last segment. Look to see if it's a product. If it's not, you're on a category page.
Yep that'll work! Thanks Drew.