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


string | within: collection
returns  string

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



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 }}
  "collection": {
    "products": [
        "url": "/products/haldon-cashmere-crew"
        "url": "/products/ace-cashmere-beanie"