How To Hide Certain Collections from the All Collections Page

Hi there!

I am wondering if there is a way to hide certain collections from the “all collections” but not hide those collections entirely on the site. Example: MY client has “View all collections” which directs customers to the page containing all collections. But She offers courses for business education that she doesn’t want every day shoppers to see. I want to hide those collections from the all collections page but still have them displayed on the separate education page.

The site is not live yet, so I can’t show you exactly but I am using the dawn theme. Let me know if you need more explanation. Thank you!

1 Like

Hi @alyssaficcaglia .

You’d have to filter those “unwanted” collections in the collections.liquid template.

You can either mark them with tags or metafields or simply filter them out by name.

Here’s an example with the “hidden-all” tag.

{% for collection in collections %}
  {% unless collection.tags contains 'hidden-all' %}
    
    {{ collection.title }}

  {% endunless %}
{% endfor %}

Metafield filtering example.

Namespace: custom

Key: hide_from_all

type: boolean

Your liquid code would be something like this

{% for collection in collections %}
  {% unless collection.metafields.custom.hide_from_all %}
    
  {% endunless %}
{% endfor %}

And if you want to filter them by handle, it would be:

{% assign hidden_handles = "education,coaching,course-bundle" | split: "," %}

{% for collection in collections %}
  {% unless hidden_handles contains collection.handle %}
    
    {{ collection.title }}

  {% endunless %}
{% endfor %}

I hope this helps!

Would this code go in the collection-list.liquid? I don’t see a collection.liquid file?

Yes, it should be collection-list.liquid

You’d need to alter this part

{% for block in section.blocks %}

with something like

{%- assign hidden_handles = "education,coaching" | split: "," -%}

{% for block in section.blocks %}
  {% assign col = block.settings.collection %}
  {% unless hidden_handles contains col.handle %}
...code skipped here...
  {% endunless %}
{% endfor %}

I am probably not doing it right, but these are not working.

I have achieved this by adding the word “private” into the slug of the collection then adding this code to the bottom of the base.css.

/* Hide collections with private in the handle /
.collection-list__item:has(a[href
=“private”]) {
display: none;
}

It basically says if the slug contains private, hide it from all collections.

You may also want to implement the below to hide the product / collections from the search bar:

https://www.youtube.com/watch?v=xQGTvHbwDDg