Skip to main content

Collection

Collection filters output or modifies content specific to the collection object and its properties.

within

string | within: collection
returns  string

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

warning

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.

Code
{% assign collection_product = collection.products | first %}

{{ collection_product.url | within: collection }}
Data
{
"collection": {
"products": [
{
"url": "/products/haldon-cashmere-crew"
},
{
"url": "/products/ace-cashmere-beanie"
}
]
}
}
Output
/collections/selling/products/ace-cashmere-beanie
On this page