Howto:NavigateWithinCollection
From Shopify Wiki
Usually products are on their own within shopify.
A Collection is just a list of products. Clicking on a product in a normal Collection overview causes shopify to completely forget which collection was used to reach the product in first place.
Some webdesigners wanted to create navigation within their collections. This tutorial explains how to add this feature to a theme which doesn't already support it.
Usually a product lives under a url such as this /products/shopify-tshirt a collection under a url like this /collections/sale. What we need to do for this feature to work is to tell shopify about the collection we are currently using while looking at a product. For this you can use the new nested url scheme /collections/sale/products/shopify-tshirt.
Change your links
Open collection.liquid and change links to your products from {{product.url}} to be aware of the collection by using the new within filter: *{{product.url | within: collection }} where collection is the collection the product is contained in ( you can use the variable collection like above in the collection.liquid file.
Adjust your product.liquid
On the product liquid you now have access to the Collection object in liquid. This object is only present if the url of the product contains the collection.
The most common use case for this feature is to create prev/next navigation. For this the Collection object received two new methods: next_product and previous_product .
Here is an example which adds navigation to the product.liquid file:
{% if collection %}
{% if collection.previous_product %}
{{ 'Previous Product' | link_to: collection.previous_product }}
{% endif %}
{% if collection.next_product %}
{% if collection.previous_product %} | {% endif %}
{{ 'Next Product' | link_to: collection.next_product }}
{% endif %}
{% endif %}
Notice that the whole block is contained in a {%if collection %} block. This ensures that nothing of this will be shown should the user be on a non collection scoped product url.

