Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Website: Juststuffisell.com
Using the simple theme.
Working on finishing up the configuration for the new site and need some assistance with a few things. First one is I need to be able to hide empty collections and sub-collections automatically and to have them repopulate as items are added to them.
I've tried a couple of processes for other themes that did not work in this one and was not able to find one that was done for the simple theme.
Any help would be greatly appreciated 🙂
Solved! Go to the solution
This is an accepted solution.
You can hide the empty collections using the condition below.
{% if collection.products_count != 0 %} ... {% endif%}
Take https://juststuffisell.com/collections as an example . The code is in sections/list-collections-template.liquid in Simple theme. I have added this condition inside the loop before the grid__item . You can use the same logic if you are using blocks too.
Bump
This is an accepted solution.
You can hide the empty collections using the condition below.
{% if collection.products_count != 0 %} ... {% endif%}
Take https://juststuffisell.com/collections as an example . The code is in sections/list-collections-template.liquid in Simple theme. I have added this condition inside the loop before the grid__item . You can use the same logic if you are using blocks too.
Thank a million!!!!
Hi Lixon_Louis
I was so happy to find your solution here and I tried immediately, but unfortunately it doesn't work on my side. I have the Theme DEBUT (VERSION 11.0.1) installed. Could that be the reason? My code looks a little bit different, but not so much…
{% for collection in collections %} <li class="grid__item {{ grid_item_width }}"> {% include 'collection-grid-item', collection_image_size: image_size %} </li> {% endfor %}
this code I changed to…
{% for collection in collections %} {% if collection.products_count != 0 %} <li class="grid__item {{ grid_item_width }}"> {% include 'collection-grid-item', collection_image_size: image_size %} </li> {% endif %} {% endfor %}
I would be very grateful if you could take a look at it. Thank you in advance
Stefanos
The solution is same for Debut. I suppose your collections are not empty then. Or are you talking about inventory_quantity? @shopany
Hi @Lixon_Louis
Thank you for your fast reply.
The collections are empty. I have a lot of empty collection right now, because I have not finished assigning the products. There is inventory available, but it's not linked / allocated to the collection.
I may have missed something in this process. I edited my theme, went to the file that was listed in the example, and added the code:
{% if collection.products_count != 0 %}
Where it was suggested to add the code. I saved the file, refreshed and when i previewed my site, the empty menu items (collections) were still visible.
Is there something I am missing here? Please advise,list-collections-template.liquid
Live Site
Hi @Lixon_Louis I have the same issue.
I follow the code that you gave but still the empty collection is visible on sidebar.
Hope you can help us too.
Thank you!
Below is How to Hide Empty Collections and display only collections that has more than one data count
<li> {% for collection in collections %}
{% if collection.products_count != 0 %}
<br><a href="{{ collection.url }}"> {{ collection.title }} <span class="count">({{collection.products_count}})</span></a>
{% endif%} {% endfor %} </li>
Hello @Lixon_Louis
I would really appreciate it if you could help me with this issue on my custom porto theme 🙂
Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025