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 %}