Potential Documentation Issue in Liquid “Whitespace Control” Example

Hi everyone,

I was reviewing the Shopify Liquid documentation under the “Whitespace control” section and came across an example that lists all product types in a collection. The example shows output like:

The 'Sale potions' collection contains the following types of products:

- Health
- Health & Beauty
- Invisibility
- Water

However, in my testing, when collection.products is empty, using the following code prevents the types from being displayed:

{%- if collection.products.size > 0 -%}
The '{{ collection.title }}' collection contains the following types of products:

{% for type in collection.all_types -%}
  {% unless type == blank -%}
    - {{ type }}
  {%- endunless -%}
{%- endfor %}
{%- endif -%}

Test data used:

{
  "collection": {
    "all_types": [
      "Health",
      "Health & Beauty",
      "Invisibility",
      "Water"
    ],
    "products": [],
    "title": "Sale potions"
  }
}

This behavior differs from the example output shown in the documentation.

Could anyone clarify whether this is a documentation oversight, or if there is a specific context in which the example output is accurate?

Thanks in advance for your guidance.

Best regards,
Masud Rana

Hey @Masud_Rana040 - thanks for flagging this, good catch.

Looking at the sample data in that example, it has “products”: (empty array), so collection.products.size > 0 would likely evaluate to false and the whole block wouldn’t render.

I’ll get this flagged internally on our end here to confirm if this is intended. Appreciate you taking the time to report it, I’ll loop back here once I have next steps!

1 Like