---
layout: default
title: collection
nav:
group: Liquid Variables
---
# collection
The collection object has the following attributes:
{% table_of_contents %}
{% comment %}
Commenting out all_products and all_products_count as I don't see a purpose for them atm. The pagination limit for products and all_products is the same, so what is the difference?
{% anchor_link "collection.all_products", "collection.all_products" %}
Returns all of the products inside a collection. Note that there is a limit of 50 products that can be shown per page. Use the pagination tag to control how many products are shown per page.
{% anchor_link "collection.all_products_count", "collection.all_products_count" %}
Returns the number of products in a collection.
Input
{% highlight html %}{% raw %} {{ collection.all_products_count }} {{ collection.all_products_count | pluralize: 'Item', 'Items' }} total {% endraw %}{% endhighlight %}Output
Returns a list of all product types in a collection.
Input
{% highlight html %}{% raw %} {% for product_type in collection.all_types %} {{ product_type | link_to_type }} {% endfor %} {% endraw %}{% endhighlight %}Output
{% anchor_link "collection.all_vendors", "collection-all_vendors" %}Returns a list of all product vendors in a collection.
Input
{% highlight html %}{% raw %} {% for product_vendor in collection.all_vendors %} {{ product_vendor | link_to_vendor }} {% endfor %} {% endraw %}{% endhighlight %}Output
{% anchor_link "collection.current_type", "collection-current_type" %} Returns the product type when filtering a collection by type. For example, you may be on a collection page filtered by a type query parameter via this URL: myshop.shopify.com/collections?types=shirts.Input
Output
Input
Output
Returns the sort order of the collection, which is set in the collection pages of the Admin.
{{ '/themes/collection-sorting.jpg' | image }} The possible outputs are: - manual - best-selling - title-ascending - title-descending - price-ascending - price-descending - created-ascending - created-descending {% anchor_link "collection.description", "collection-description" %}Returns the description of the collection.
{% anchor_link "collection.handle", "collection-handle" %}Returns the handle of a collection.
{% anchor_link "collection.id", "collection-id" %}Returns the id of the collection.
{% anchor_link "collection.image", "collection-image" %}Returns the collection image. Use the collection_img_url filter to link it to the image file on the Shopify CDN.
Input
{% highlight html %}{% raw %} {{ collection.image | collection_img_url: 'medium' }} {% endraw %}{% endhighlight %}Output
Returns the collection image's alt tag.
{% endcomment %} {% anchor_link "collection.image.src", "collection-image-src" %}Returns the relative URL to the collection image.
Input
{% highlight html %}{% raw %} {{ collection.image.src | collection_img_url: 'medium' }} {% endraw %}{% endhighlight %}Output
nil if there is no next product.
This output can be used on the product page to output "next" and "previous" links on the product.liquid template. For more information, see How to Navigate within a Collection.
{% anchor_link "collection.previous_product", "collection-previous_product" %}
Returns the URL of the previous product in the collection. Returns nil if there is no previous product.
This output can be used on the product page to output "next" and "previous" links on the product.liquid template. For more information, see How to Navigate within a Collection.
{% anchor_link "collection.products", "collection-products" %}
Returns all of the products inside a collection. Note that there is a limit of 50 products that can be shown per page. Use the pagination tag to control how many products are shown per page.
{% anchor_link "collection.products_count", "collection-products_count" %}
Returns the number of products in a collection.
Input
{% highlight html %}{% raw %} {{ collection.all_products_count }} {{ collection.all_products_count | pluralize: 'Item', 'Items' }} total {% endraw %}{% endhighlight %}Output
Returns the name of the custom collection template assigned to the collection, without the collection. prefix or the .liquid suffix. Returns nil if a custom template is not assigned to the collection.
Input
{% highlight html %}{% raw %} {{ collection.template_suffix }} {% endraw %}{% endhighlight %}Output
Returns the title of the collection.
Input
{% highlight html %}{% raw %}Output
Returns all tags of all products in a collection.
{% anchor_link "collection.url", "collection-url" %}Returns the URL of the collection.