Create an array in Shopify's liquid
Still works in 2023!

According to Shopify’s documentation, you can’t create arrays with liquid.
Unfortunately, that means you can’t do something simple and clean like this:
{% assign fruits = \["orange", "apple", "peach"] %}
Thankfully, there’s a workaround!
You can use the split
filter to create accessible arrays in liquid:
{% assign fruits = "orange,apple,peach" | split: ',' %}
It’s not particularly elegant, but it does the job. You can then loop over this array and do whatever you like:
{% for fruit in fruits %}
{{ fruit }}
{% endfor %}
And voila.
Being able to capture arrays with liquid opens up a lot of possible applications for your Shopify store!
Find this helpful? You might also like our Shopify apps:
- Customer Fields allows you to build custom registration forms and retrieve valuable data from customers at just the right time.
- Meteor Mega Menu offers a variety of beautiful dropdown menu templates which you can attach to your existing Shopify navigation, meaning your store could have a menu makeover in minutes.
Build with Customer Fields
Customer Fields is more than just a form builder. It’s a platform for developers to build unique experiences on Shopify using zero-party and first-party data.
See documentation