Create an array in Shopify's liquid

June 6, 2016

According to Shopify’s documentation, you can’t create arrays with liquid.

So it’s not as clean as something like:

{% assign fruits = ["orange", "apple", "peach"] %}

But instead you can create accessible arrays in liquid using the split filter:

{% assign fruits = "orange,apple,peach" | split: ',' %}

Even though is not particularly elegant, it does the job. You can then loop over this array and do whatever you like:

{% for fruit in fruits %}
  {{ fruit }}
{% endfor %}

And voila.


Helium builds apps, themes, and stores on Shopify.

Learn more