How to hide subcollections when a child page doesn't exist?

Topic summary

A user is seeking help to hide subcollections in their Shopify store when no child page exists for them.

Specific Issue:

  • Under “HEST” → “BID”, subcollections display correctly
  • Under “Trensebid”, subcollections appear but shouldn’t link to anything since no child page exists

Context Provided:

  • The user shared their website URL (animondo.dk/collections/horse)
  • Two screenshots illustrate the problem: one showing correct behavior, another showing unwanted subcollection links
  • Code from “main-collection.liquid” file was included, though it appears corrupted or improperly formatted in the post

Current Status:
The discussion remains open with no responses or solutions provided yet. The user needs guidance on conditional logic to detect and hide subcollections that lack associated child pages.

Summarized with AI on November 16. AI used: claude-sonnet-4-5-20250929.

I’m trying to hide the subcollections then a child page doesn’t exist. https://animondo.dk/collections/horse

Under “HEST” → “BID” it’s okay the subcollections are shown

But under “Trensebid” it should link to anything.

This is my “main-collection.liquid”

{% paginate collection.products by section.settings.coll_num_per_page_int %}

{%- liquid
if section.settings.show_image_behind_heading and collection.image
assign header_image_enabled = true
else
assign header_image_enabled = false
endif
assign current_sort = collection.sort_by | default: collection.default_sort_by

assign show_filters = section.settings.enable_filtering
if collection.filters == empty
assign show_filters = false
endif
-%}

{%- liquid
if section.settings.enable_subcoll and section.settings.subcoll_menu != blank
assign current_link_parent = false
for link in linklists[section.settings.subcoll_menu].links
if link.links != empty
if link.type == ‘collection_link’ and link.object.handle == collection.handle
assign current_link_parent = link
break
elsif link.type == ‘catalog_link’ and collection.handle == ‘all’
assign current_link_parent = link
break
endif
endif
if link.links != blank and current_link_parent == false
for child_link in link.links
if child_link.type == ‘collection_link’ and child_link.object.handle == collection.handle
if child_link.links == empty
assign current_link_parent = link
else
assign current_link_parent = child_link
endif
break
endif
if child_link.type == ‘catalog_link’ and collection.handle == ‘all’
if child_link.links == empty
assign current_link_parent = link
else
assign current_link_parent = child_link
endif
break
endif
if child_link.links != blank and current_link_parent == false
for child_child_link in child_link.links
if child_child_link.type == ‘collection_link’ and child_child_link.object.handle == collection.handle
assign current_link_parent = child_link
break
elsif child_child_link.type == ‘catalog_link’ and collection.handle == ‘all’
assign current_link_parent = child_link
break
endif
endfor
endif
endfor
endif
endfor
endif
-%}

{%- if current_link_parent -%}
{%- assign subcoll_count = 0 -%}
{% capture subcollection_html %}
{% if section.settings.subcoll_style == ‘buttons’ %}

{%- for link in current_link_parent.links -%} {%- unless link.object.handle == collection.handle or link.type != 'collection_link' -%} {%- assign subcoll_count = subcoll_count | plus: 1 -%} {{ link.title | escape }} {%- endunless -%} {%- endfor -%}
{% else %} {% unless section.settings.subcoll_gall_full_width %}
{% endunless %}
{%- for link in current_link_parent.links -%} {%- unless link.object.handle == collection.handle or link.type != 'collection_link' -%} {%- assign subcoll_count = subcoll_count | plus: 1 -%} {%- endunless -%} {%- endfor -%}
{% unless section.settings.subcoll_gall_full_width %}
{% endunless %} {% endif %} {% endcapture %} {%- liquid if subcoll_count < 2 assign subcollection_html = '' endif -%} {%- endif -%}

{% if header_image_enabled %}
{%- liquid
assign show_header = false
if section.settings.show_title
assign show_header = true
endif
if collection.description != blank and section.settings.coll_desc_pos == ‘above’
assign show_header = true
endif
if current_link_parent and section.settings.subcoll_style == ‘buttons’
assign show_header = true
endif
-%}
{%- if show_header -%}

{%- if section.settings.show_title -%}

{{ collection.title | escape }}

{%- endif -%}

{% if collection.description != blank and section.settings.coll_desc_pos == ‘above’ %}

{{ collection.description }}
{% endif %}

{%- if current_link_parent and section.settings.subcoll_style == ‘buttons’ -%}
{{ subcollection_html }}
{%- endif -%}

{%- endif -%} {% else %} {{ subcollection_html }} {%- liquid assign show_header = false if section.settings.show_title assign show_header = true endif if collection.description != blank and section.settings.coll_desc_pos == 'above' assign show_header = true endif -%} {%- if show_header -%}
{%- if section.settings.show_title -%}

{{ collection.title | escape }}

{%- endif -%}

{% if collection.description != blank and section.settings.coll_desc_pos == ‘above’ %}

{{ collection.description }}
{% endif %}
{% endif %} {% endif %}

{%- if current_link_parent and header_image_enabled and section.settings.subcoll_style != ‘buttons’ -%}
{{ subcollection_html }}
{%- endif -%}

{% if section.settings.show_total and paginate.items > 0 %}

{{ 'collections.general.product_count' | t: count: paginate.items }}
{% endif %}
{% if section.settings.coll_show_sort %}
{{ 'collections.sorting.title' | t | escape }}
{%- for option in collection.sort_options -%} {%- if current_sort == option.value -%} {{ option.name | escape }} {%- break -%} {%- endif -%} {%- endfor -%} {% render 'svg-chevron-down', stroke_width: 1.3 %}
{%- for option in collection.sort_options -%} {%- if option.value != 'manual' or section.settings.coll_show_feat or collection.default_sort_by == 'manual' -%} {{ option.name | escape }} {%- endif -%} {%- endfor -%}
{% endif %}
{% if section.settings.coll_show_sort or show_filters %} {% render 'faceted-filters', filter_context: collection, clear_url: collection.url, current_sort: current_sort %} {% endif %}
{% if collection.products.size == 0 %}
{{ 'collections.general.no_matches' | t }}
{% else %}
{%- liquid if settings.prod_thumb_shape == 'portrait-23' assign chosen_aspect_ratio = 0.67 elsif settings.prod_thumb_shape == 'portrait-45' assign chosen_aspect_ratio = 0.8 elsif settings.prod_thumb_shape == 'square' assign chosen_aspect_ratio = 1.0 elsif settings.prod_thumb_shape == 'landscape-54' assign chosen_aspect_ratio = 1.25 elsif settings.prod_thumb_shape == 'landscape-32' assign chosen_aspect_ratio = 1.50 elsif settings.prod_thumb_shape == 'tallest' assign chosen_aspect_ratio = 99 for product in collection.products if product.featured_media.preview_image.aspect_ratio < chosen_aspect_ratio assign chosen_aspect_ratio = product.featured_media.preview_image.aspect_ratio endif endfor else assign chosen_aspect_ratio = 0 for product in collection.products if product.featured_media.preview_image.aspect_ratio > chosen_aspect_ratio assign chosen_aspect_ratio = product.featured_media.preview_image.aspect_ratio endif endfor endif -%} {% for product in collection.products %} {% render 'product-block', product: product, custom_aspect_ratio: chosen_aspect_ratio, animate: true %} {% endfor %}
{% endif %}
{% render 'pagination-control', paginate: paginate %}

{% endpaginate %}

{% if collection.description != blank and section.settings.coll_desc_pos == ‘below’ %}

{{ collection.description }}
{% endif %}

{% schema %}
{
“name”: “Collection pages”,
“settings”: [
{
“type”: “header”,
“content”: “Heading”
},
{
“type”: “checkbox”,
“id”: “show_title”,
“label”: “Show collection title”,
“default”: true
},
{
“type”: “checkbox”,
“id”: “show_image_behind_heading”,
“label”: “Show collection image behind title”,
“default”: true
},
{
“type”: “select”,
“id”: “heading_image_height”,
“label”: “Heading image height”,
“options”: [
{
“value”: “small”,
“label”: “Compact”
},
{
“value”: “medium”,
“label”: “Small”
},
{
“value”: “large”,
“label”: “Medium”
},
{
“value”: “huge”,
“label”: “Large”
}
],
“default”: “medium”
},
{
“id”: “overlay_style”,
“type”: “select”,
“label”: “Overlay style”,
“default”: “shadow”,
“options”: [
{
“value”: “full”,
“label”: “Tint”
},
{
“value”: “box”,
“label”: “Box”
},
{
“value”: “shadow”,
“label”: “Text shadow”
},
{
“value”: “full image-overlay–bg-shadow”,
“label”: “Text shadow and tint”
},
{
“value”: “no_background”,
“label”: “No background”
}
]
},
{
“type”: “select”,
“id”: “coll_desc_pos”,
“label”: “Description position”,
“default”: “above”,
“options”: [
{
“value”: “above”,
“label”: “Below collection title”
},
{
“value”: “below”,
“label”: “Below products”
}
]
},
{
“type”: “header”,
“content”: “Layout”
},
{
“type”: “range”,
“id”: “coll_num_per_page_int”,
“min”: 16,
“max”: 50,
“step”: 2,
“label”: “Number of products to show per page”,
“default”: 24
},
{
“type”: “range”,
“id”: “grid”,
“label”: “Products per row”,
“min”: 2,
“max”: 5,
“step”: 1,
“default”: 4
},
{
“type”: “checkbox”,
“id”: “show_vendor”,
“label”: “Show product vendors”,
“default”: false
},
{
“type”: “checkbox”,
“id”: “show_total”,
“label”: “Show product total”,
“default”: true
},
{
“type”: “header”,
“content”: “Filters”
},
{
“type”: “checkbox”,
“id”: “enable_filtering”,
“label”: “Enable filtering”,
“info”: “Customize filters”,
“default”: true
},
{
“type”: “checkbox”,
“id”: “collapse_tag_sidebar_by_default”,
“label”: “Collapse filter column”,
“default”: false
},
{
“type”: “select”,
“id”: “collapse_filters_method”,
“label”: “Filter row collapse”,
“default”: “over-12”,
“options”: [
{
“value”: “none”,
“label”: “None”
},
{
“value”: “over-6”,
“label”: “Over 6 items”
},
{
“value”: “over-12”,
“label”: “Over 12 items”
},
{
“value”: “over-18”,
“label”: “Over 18 items”
},
{
“value”: “all”,
“label”: “All rows”
}
]
},
{
“type”: “checkbox”,
“id”: “show_filter_counts”,
“label”: “Show filter counts”,
“default”: false
},
{
“type”: “checkbox”,
“id”: “show_disabled_filters”,
“label”: “Show filters with zero results”,
“default”: true
},
{
“type”: “checkbox”,
“id”: “ajax_products”,
“label”: “Filter and sort collections without loading a new page”,
“default”: true,
“info”: “Some apps require this to be disabled”
},
{
“type”: “checkbox”,
“id”: “auto_apply_hide_unavailable”,
“label”: “On selecting a filter, automatically apply ‘Hide out of stock’”,
“default”: false,
“info”: “Requires Availability filter to be enabled”
},
{
“type”: “checkbox”,
“id”: “enable_sticky_filter”,
“label”: “Enable stick on scroll”,
“default”: true
},
{
“type”: “checkbox”,
“id”: “filter_two_columns”,
“label”: “Two column filter values”,
“default”: false
},
{
“type”: “checkbox”,
“id”: “coll_show_sort”,
“label”: “Show sorting dropdown”,
“default”: true
},
{
“type”: “checkbox”,
“id”: “coll_show_feat”,
“label”: “Show ‘Featured’ in sorting dropdown”,
“default”: false
},
{
“type”: “header”,
“content”: “Subcollections”
},
{
“type”: “paragraph”,
“content”: “The current collection is located in the menu, and any other collections within that dropdown menu are displayed. Read more
},
{
“type”: “checkbox”,
“id”: “enable_subcoll”,
“label”: “Enable subcollections”,
“info”: “A menu must be selected below”,
“default”: true
},
{
“type”: “link_list”,
“id”: “subcoll_menu”,
“label”: “Subcollections menu”,
“info”: “This is usually your main menu”,
“default”: “main-menu”
},
{
“type”: “select”,
“id”: “subcoll_style”,
“label”: “Subcollections style”,
“default”: “buttons”,
“options”: [
{
“value”: “buttons”,
“label”: “Buttons”
},
{
“value”: “gallery”,
“label”: “Gallery”
}
]
},
{
“type”: “header”,
“content”: “Subcollection gallery layout”
},
{
“type”: “select”,
“id”: “subcoll_gall_shape”,
“label”: “Image shape”,
“default”: “sq”,
“options”: [
{
“value”: “l-21”,
“label”: “Landscape (2x1)”
},
{
“value”: “l-64”,
“label”: “Landscape (6x4)”
},
{
“value”: “l-5x4”,
“label”: “Landscape (5x4)”
},
{
“value”: “sq”,
“label”: “Square (1x1)”
},
{
“value”: “p-4x5”,
“label”: “Portrait (4x5)”
}
]
},
{
“type”: “select”,
“id”: “image_position”,
“label”: “Image alignment”,
“info”: “Used to keep the subject of your image in view”,
“default”: “center center”,
“options”: [
{
“value”: “top left”,
“label”: “Top left”
},
{
“value”: “top center”,
“label”: “Top center”
},
{
“value”: “top right”,
“label”: “Top right”
},
{
“value”: “center left”,
“label”: “Middle left”
},
{
“value”: “center center”,
“label”: “Middle center”
},
{
“value”: “center right”,
“label”: “Middle right”
},
{
“value”: “bottom left”,
“label”: “Bottom left”
},
{
“value”: “bottom center”,
“label”: “Bottom center”
},
{
“value”: “bottom right”,
“label”: “Bottom right”
}
]
},
{
“id”: “subcoll_gall_enable_margin”,
“type”: “checkbox”,
“label”: “Add spacing”,
“default”: true
},
{
“id”: “subcoll_gall_full_width”,
“type”: “checkbox”,
“label”: “Full page width”,
“default”: false
},
{
“id”: “subcoll_gall_overlay_style”,
“type”: “select”,
“label”: “Overlay style”,
“default”: “shadow”,
“options”: [
{
“value”: “full”,
“label”: “Tint”
},
{
“value”: “box”,
“label”: “Box”
},
{
“value”: “shadow”,
“label”: “Text shadow”
},
{
“value”: “full image-overlay–bg-shadow”,
“label”: “Text shadow and tint”
},
{
“value”: “no_background”,
“label”: “No background”
}
]
},
{
“type”: “select”,
“id”: “subcoll_gall_text_alignment”,
“label”: “Text overlay position”,
“options”: [
{
“value”: “top left”,
“label”: “Top left”
},
{
“value”: “top center”,
“label”: “Top center”
},
{
“value”: “top right”,
“label”: “Top right”
},
{
“value”: “center center”,
“label”: “Middle”
},
{
“value”: “bottom left”,
“label”: “Bottom left”
},
{
“value”: “bottom center”,
“label”: “Bottom center”
},
{
“value”: “bottom right”,
“label”: “Bottom right”
}
],
“default”: “center center”
},
{
“type”: “select”,
“id”: “subcoll_gall_mobile_layout”,
“label”: “Mobile layout”,
“info”: “Mobile layout always uses 5x4 images”,
“default”: “2”,
“options”: [
{
“value”: “1”,
“label”: “1 item”
},
{
“value”: “2”,
“label”: “2 items”
},
{
“value”: “hide”,
“label”: “Hide”
}
]
}
]
}
{% endschema %}