To access specific collection attributes, you must know collection handle and use this kind of code :

{{ collections['the-handle'].url }}

So to achieve what you want to do, here is what you could do:

{% assign collection_handle = 'the-handle-of-collection-you-want' %}
{% for product in collections[collection_handle].products %}
    Do your stuff
{% endfor %}

Note that you cannot access a collection through its title. Only handle.

Learning more about what's handle: https://help.shopify.com/themes/liquid/basics/handle

HTH

Answer from Alice Girard on Stack Overflow
🌐
Shopify
shopify.dev › docs › api › liquid › objects › collection
Liquid objects: collection
Only filters relevant to the current collection are returned. Filters will be empty for collections that contain over 5000 products. To learn about supporting filters in your theme, refer to Support storefront filtering. ... The handle of the collection.
🌐
Entaice
entaice.com › blog › shopify-liquid-get-collection-by-handle
How to Fetch Collections in Shopify Using Liquid's Handle | Entaice
September 7, 2023 - To grab a collection by its handle in Liquid, you’ll be using something called an object. In Shopify’s Liquid world, objects hold data about different parts of your store like products, ...
🌐
HulkApps
hulkapps.com › home › shopify hub › a complete guide on how to get collection handle in shopify
A Complete Guide on How to Get Collection Handle in Shopify
April 11, 2024 - A collection handle is a unique, ... code. ... You can find a collection's handle by accessing the 'handle' attribute of the 'collection' Liquid object on collection pages....
🌐
ShopKeeper
shopkeepertools.com › docs › global-content › product-collections
Output Based on Product Collections | ShopKeeper
This code will output different text based on what collection your product is in. This code works by checking the handle of collections. Add this Code to My Content Change the values in bold to fit your needs. Be sure the "use Liquid" checkbox is checked. {% assign collection_handles = product.collections |…
🌐
Shopify Community
community.shopify.com › technical q&a
If product is in a specific collection, show specific code on page
April 14, 2022 - So I am working on a product specifications table for our website and I would like for the code to show certain aspects of that table based off an if else or case statement. For example, we have various appliances and i…
Find elsewhere
🌐
Foobartel
foobartel.com › articles › shopify-collections
Shopify: Achieving Collections in Collections - foobartel.com
The collection.looks.liquid file contains the following code: First of all, I’m checking if the current collection handle is “looks-girls”. If that’s the case, I go ahead and find all collections with a name containing “looks-girls-“ — the important part here is the trailing “-“ in the handle.
🌐
GitHub
gist.github.com › 1002801 › 0c1c54333ce052f4cc202a766a51925acc4c190c
Related Products — to add to product.liquid
{% if collection and collection.all_products_count > 4 %} {% assign col = collection.handle %} {% else %} {% assign col = product.collections.last.handle %} {% endif %} {% for tag in product.tags %} {% if tag contains 'meta-related-collection-' %} {% assign col = tag | remove: 'meta-related-collection-' %} {% assign collection = collections[col] %} {% capture limit %}{{ collection.products_count | plus: 1 }}{% endcapture %} {% endif %} {% endfor %} {% if col and collections[col].all_products_count > 0 %} <br class="clear" /> <br class="clear" /> <h4 class="title center">{{ 'products.product.re
🌐
Shopify
shopify.github.io › liquid-code-examples › example › collection-list
Collection list | Shopify Liquid code examples
--> {%- if collection.image -%} {%- assign collection_image = collection.image -%} {%- elsif collection.products.first and collection.products.first.images != empty -%} {%- assign collection_image = collection.products.first.featured_image -%} {%- else -%} {%- assign collection_image = blank -%} {%- endif -%} <a href="{{ collection.url }}"> <img src="{{ collection_image | img_url: '480x' }}" alt=""> {{ collection.title }} </a> </li> {%- endfor -%} </ul>
🌐
Markdunkley
cheat.markdunkley.com
Shopify Cheat Sheet - Liquid variables
If using a custom product template (like product.bike-landing.liquid) then it will return the name of the template (bike-landing) ... Returns the variant object if passed in through the url (ex: ?variant=123 would return "123"). ... Returns the variant objet if there is a ?variant= url parameter. If there is no param the first variant with inventory will be selected. ... Returns a list of collections a product is listed in. ... Returns a list of the product's tags (represented by simple strings).
🌐
Entaice
entaice.com › blog › shopify-collection-liquid
Unlocking the Secrets of Shopify Collections with Liquid | Entaice
May 20, 2023 - Liquid supports pagination out of the box: {% paginate collection.products by 20 %} {% for product in collection.products %} <li>{{ product.title }} - {{ product.price | money_with_currency }}</li> {% endfor %} {% endpaginate %} This way, only 20 products are loaded per page, reducing load times and making the user experience smoother. By now, you should have a good grasp of how Shopify collections and Liquid can work together to create a dynamic, responsive, and organized online shop.
🌐
Shopify Community
community.shopify.com › shopify discussion
Loop through a collection using a collection ID
May 15, 2023 - Hi there, Trying to figure out how to loop through a collection using the collection ID. Is this possible? Right now I’m using the collection name, ie: collections['collection-name'].products but needing to transition a…
🌐
Shopify
shopify.dev › docs › api › liquid › objects › all_products
Liquid objects: all_products
_products object has a limit of 20 unique handles per page. If you want more than 20 products, then consider using a collection instead. ... _products to access a product by its handle. This returns the product object for the specified product.