I design .

I'm Ketan ‐ A Melbourne web designer and developer
with over 20 years of industry experience.

Head icon.

Shopify Tips

Liquid tip: Removing null values from an array

← Journal

Here’s a little trick I learned for removing null or empty values from an array in Shopify’s liquid.

By using the compact filter will return a nice clean array. Using this filter is especially useful when working with comma-separated lists, like in the example below.

{% assign my_list = "one,two,three,four,five,,six,seven" %}
{% assign my_array = my_list | split: ',' | compact %}

Sketch sitemap library available for US$14 on Gumroad.