Mastering Shopify: How to Display Sub-Collections on Your Collection Pages
Hey store owners!
One of the most common questions I hear, especially from folks looking to create a really organized and intuitive shopping experience, is about displaying sub-collections on their main collection pages. You know, like having a 'Women's Clothing' collection, and then right there on that page, you see cards for 'Dresses,' 'Tops,' and 'Bottoms' before diving into the products themselves. It’s a fantastic way to guide your customers deeper into your catalog, improving both user experience and potentially boosting conversions.
Recently, a thread popped up in the Shopify community, initiated by Habib_Rayan, asking exactly this: "How to Show Sub-Collections on a Collection Page?" Habib had used Shopify's new conditional logic in the Admin to set up these 'sub-collections' and was looking for the Liquid object to display them. As a Shopify migration expert at Shopping Cart Mover, I know this is a topic that often causes a bit of head-scratching, so let's dive into what the community experts had to say and the most reliable ways to get this done.
The Current Reality: Shopify's Native Sub-Collections Aren't Quite Storefront-Ready (Yet!)
The first thing to understand, as keenly pointed out by several experts in the thread like Ploqo, is that what Shopify calls 'sub-collections' in the new Admin feature (specifically, the 'CollectionSubCollectionSource' in the API) isn't yet fully exposed to Liquid on the storefront. Ploqo did some thorough testing, checking collection | json, collection.sources, collection.sub_collections, and even the Storefront API, and confirmed: "There is no Liquid object for it yet."
This new feature is more about a "product selection process" – essentially, a way for a collection to automatically include products from other collections based on conditional logic. It's a powerful tool for managing product inventory within collections, but it doesn't, as we traditionally understand it, create a nested hierarchical collection structure with a direct Liquid object you can loop through to display on your storefront.
Why You Can't Rely on product.collections for Sub-Collections
Another tempting but unreliable approach mentioned in the thread is to loop through collection.products and then read product.collections. Ploqo explicitly warned against this, stating: "Deriving it by looping collection.products and reading product.collections looks tempting but is not safe." The reason? This method will return *every* collection those products happen to sit in, not just the specific sub-collections you intend to display. This can lead to irrelevant or duplicate collection links, confusing your customers.
The Robust Solution: Leveraging Shopify Metafields and Custom Liquid
Given the current limitations, the most reliable and flexible method to display sub-collections on your collection pages involves using Shopify's powerful metafields in conjunction with a custom Liquid section. This approach gives you full control over which sub-collections appear and how they are presented.
Step 1: Define Your "Sub-Collections" Metafield
First, you need to create a custom metafield definition for your collections to store the links to your sub-collections.
- Go to your Shopify Admin: Settings > Custom data > Collections.
- Click Add definition.
- Name it something clear, like "Sub collections".
- Set the Type to List of collections. This is crucial as it allows you to select multiple collections.
- Ensure Storefront API access is checked.
- Click Save.
Step 2: Populate Your Parent Collection's Metafield
Now, you'll assign the actual sub-collections to your parent collection using the metafield you just created.
- Navigate to Products > Collections in your Shopify Admin.
- Open the parent collection (e.g., "Women's Clothing") where you want to display sub-collections.
- Scroll down to the Metafields section (usually at the bottom).
- Find your newly created "Sub collections" metafield and click on it.
- Pick the sub-collections (e.g., "Dresses", "Tops", "Bottoms") that you want to display on this parent collection page.
- Click Save.
Step 3: Add a Custom Liquid Section to Your Collection Template
Next, you'll add a section to your theme's collection template where the sub-collections will be rendered.
- Go to Online Store > Themes.
- Find your current theme and click Customize.
- In the theme editor, navigate to a Collection page (you might need to select it from the dropdown at the top).
- In the left sidebar, under "Sections", click Add section.
- Search for and select Custom Liquid.
Step 4: Implement the Liquid Code for Display
Paste the following Liquid and CSS code into the Custom Liquid box. This code will fetch the sub-collections from your metafield and display them as visually appealing cards.
{%- assign subs = collection.metafields.custom.sub_collections.value -%}
{%- if subs != blank -%}
{%- for sub in subs -%}
{%- if sub.featured_image -%}
{%- endif -%}
{{ sub.title }}
{{ sub.all_products_count }} products
{%- endfor -%}
{%- endif -%}
- The
assignline retrieves the list of collections from your metafield. - The
if subs != blankensures the section only renders if sub-collections are assigned. - The
for sub in subsloop iterates through each selected sub-collection. - Inside the loop, it creates a link (
) to the sub-collection, displays its featured image (if available), title, and product count. - The included
block provides basic CSS to arrange these sub-collections into a responsive grid of cards, making them visually appealing. You can customize this CSS to match your theme's aesthetic.
Click Save.
Step 5: Review and Position Your New Section
After saving, you'll see the sub-collection cards render on your collection page, typically above the main product grid. You can drag and drop the "Custom Liquid" section in the theme editor's sidebar to adjust its position on the page.
Theme-Specific Solutions
While the metafield approach is universally reliable, it's worth noting, as Joshua827 mentioned, that "some themes have a nested collections block that does it too." Always check your theme's documentation or its customization options. Some premium themes might offer built-in sections or blocks specifically designed to display sub-collections, potentially simplifying the process.
Why This Setup Benefits Your Store
Implementing sub-collections effectively on your collection pages offers significant advantages:
- Enhanced User Experience (UX): Customers can quickly grasp the product categories within a larger collection, making navigation intuitive and reducing bounce rates.
- Improved Search Engine Optimization (SEO): A clear, hierarchical structure with good internal linking helps search engines understand your site's content, potentially improving your rankings.
- Visual Appeal: Well-designed sub-collection cards make your collection pages more engaging and professional.
Looking Ahead
While the direct Liquid object for Shopify's native sub-collections isn't available on the storefront today, Shopify is constantly evolving. It's possible that in future updates, this functionality will be exposed, making the process even more streamlined. Until then, the metafield approach remains the most robust and flexible solution for merchants seeking to create a truly organized and navigable store.
Organizing your Shopify store's navigation is key to customer satisfaction and sales. If you find yourself needing more complex customizations, migrating an existing store, or simply want expert advice on optimizing your Shopify setup, our team at Shopping Cart Mover is here to help. We specialize in making your e-commerce journey smooth and successful. If you're just starting your e-commerce journey or considering a platform switch, remember that a well-structured store on a robust platform like Shopify can make all the difference. You can start your Shopify store today and begin building an intuitive shopping experience.