How do I hide a collection from the collection list with the Dawn theme?

Hello:
I want to hide a specific collection from the collection list but the collection page itself can still be visible and accessible through URL. I’ve seen many solutions online but none of them is for the Dawn theme and Dawn theme’s code editor is different from the others. Here’s the link: https://www.unidshop.com/collections/

Basically I want the collection without a proper icon to be invisible yet can still be accessed by customers with a link. Changing it’s availability would make in completely inaccessible to even myself, so that won’t work. Is there any way to do that?

Thanks to anyone for their help.

1 Like

Hi @Wayne18 , go to edit code > sections > main-list-collections.
Find this part:

{%- for collection in collections -%}
        - {% render 'card-collection', card_collection: collection, media_aspect_ratio: section.settings.image_ratio, columns: 3 %}
        

      {%- endfor -%}

And replace it with:

{%- for collection in collections -%}
{% if collection.handle == "cherry-offer" %}
{% else %}
      - {% render 'card-collection', card_collection: collection, media_aspect_ratio: section.settings.image_ratio, columns: 3 %}
      

{% endif %}
{%- endfor -%}

I suppose that you’re talking about ‘cherry-offer’ - code above will hide it from collection list page. :slightly_smiling_face:

2 Likes

@MarinaPetrovic

It worked. Thank you!

So what if I have to create new collections in the future and want to hide them as well? Do I need to put the name of the collection in the same line of codes or create a new line of codes with the collection name?

@MarinaPetrovic

Please answer. I will have to make more collections in the future and I need to know now how to hide more than one collection at once. Thank you.

Hi @Wayne18 , when you add a new collection you should just add it like this to the existing code:

{%- for collection in collections -%}
{% if collection.handle == "cherry-offer" or collection.handle == "YOUR-NEW-COLLECTION" %}
{% else %}
      - {% render 'card-collection', card_collection: collection, media_aspect_ratio: section.settings.image_ratio, columns: 3 %}
      
{% endif %}
{%- endfor -%}
7 Likes

@MarinaPetrovic

Thank you so much!

Thank you Its working.

@MarinaPetrovic i was looking for this exact solution - this solved it beautifully. Thank you for the help. @Wayne18 thanks for posting this scenario - :slightly_smiling_face:

Glad I could help! :blush:

1 Like

Hi, Can your code use as much as I want? it only worked for one collection and it didn’t work for other collections

yes it works for multiple collections - refer to the second code shared by @MarinaPetrovic

{%- for collection in collections -%}
{% if collection.handle == “cherry-offer” or collection.handle == “YOUR-NEW-COLLECTION” %}
{% else %}

  • {% render 'card-collection', card_collection: collection, media_aspect_ratio: section.settings.image_ratio, columns: 3 %}
  • {% endif %} {%- endfor -%}

    Hello! I think this may be the solution I’m looking for, but the code I’m working with is slightly different so it won’t accept the changes. Here is the code I’m working with that appears to be the closest to your example:

    {% for collection in collections %}
                  {% render 'collection-block', collection: collection, custom_aspect_ratio: chosen_aspect_ratio, animate: true %}
                {% endfor %}
              
            
    
            {% render 'pagination-control', paginate: paginate %}
    
          {% endpaginate %}
    
        {% else %}
    

    Will this fix still work for me with some adjustments?

    Thanks so much!

    Thanks so much! This is what I also needed. I also want the products in this collection to not show in the all products list. I’m still looking for that. Please let me know if you’ve already solved this.

    Actually not working for me. Code saves correctly. Even a simple change to the number of columns doesn’t work for me. Thanks anyway. I’ll keep looking.

    Hi robin
    Are you working on the sections > main-list-collections file? If yes, just copy Marina’s code and then insert the names of your collection that you wish to hide within “”. See screenshot from my code below for reference. I have hidden multiple collections. Point to note is that the name of the collection needs to be copied from the URL as it may be different to the display name.

    Thank you for responding! I am working on sections > main-list-collections file, but my code looks a little different. I feel like I’m probably just pasting the code in the wrong place as a result - I don’t really know much HTML but I know enough to know something isn’t right lol. Here’s a screenshot of the code I’m working with. Thanks for your help!

    Hi @robin87 , can you explain what exactly do you want to achieve? If you’d just like to hide some of the collections, replace this:

    {% for collection in collections %}
                  {% render 'collection-block', collection: collection, custom_aspect_ratio: chosen_aspect_ratio, animate: true %}
                {% endfor %}
    

    with:

    {% for collection in collections %}
    {% if collection.handle == "YOUR_COLLECTION_HANDLE" %}
    {% else %}
     {% render 'collection-block', collection: collection, custom_aspect_ratio: chosen_aspect_ratio, animate: true %}
    {% endif %}
    {% endfor %}
    

    Ok well I’m definitely having a “my car is making a noise, I swear!” moment, because I just got it to work lol thank you all for your patience with me! This is a really helpful little trick and I’ll be making good use of it!

    Hi All,

    My code is not the same as your, i tried to amend the code but it was getting worst, can anyone help on this? I just want to hide the collection on the collection list, but keep on showing it in the home page, can one can help? my code is like below…

    {%- for collection in collections -%}

  • 1 Like

    JacJacC,

    Try adding the following after {%- for collection in collections -%}:

    {% if collection.handle == "frontpage" %}
              {%- continue -%} {# Skip rendering this collection #}
            {% else %}
    

    I had the exactly the same codes as yours, but these codes worked. ChatGPT could be something solid…