Skip to main content

within

string | within: collection
returns string

Generates a product URL within the context of the provided collection.

When the collection context is included, you can access the associated collection object in the product template.


Caution

Because a standard product page and a product page in the context of a collection have the same content on separate URLs, you should consider the SEO implications of using the within filter.


{%- assign collection_product = collection.products.first -%}

{{ collection_product.url | within: collection }}

Output

/collections/sale-potions/products/draught-of-immortality
Was this page helpful?