Dawn Theme: Change URL structure to add collections

Hi all -

I’m trying to update the url structure to include the collection name when you click on a product.

Instead of having product/jabonera I want collections/bathroom/product/jabonera for example.

I have seen many way to do it online adding within:collections to the product liquid file. But I can’t seem to accomplish it.

Please help!

Hi there,

What you are asking is possible with the liquid filter you mentioned: https://shopify.dev/docs/api/liquid/filters#within

So something along:

{{ product.title }}

as long as you are browsing on a collection page.

If you’re not browsing on a collection page, then the collection object is not accessible and you can’t do what you’re asking. Why? Because a product might belong to multiple collections, so which one should it be? You’d need custom code to pick the first collection that the product belongs to (for instance), but this don’t really make sense unless you have a specific use case.

Thanks for the response MaxDesign. From an SEO standpoint would it not help to have the main collection in the name? This is my ultimate goal.

Did anyone figure this out yet?