Create an array in Shopify's liquid

Jun 06, 2015 | Blog

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.

Recent Articles

Introducing Relatable

Keeping things organized within a Shopify store can be hard, so we built Relatable to help with that.

Why we use Cloud66 to launch Ruby on Rails apps

We use Cloud66 for deploy Ruby on Rails apps, and we love it.

5 Common Pitfalls when Developing a Shopify Theme

Learn some tips on developing Shopify themes and some pitfalls to avoid. Build Shopify themes that perform and are easy to update and edit.

How to create a Shopify email link from your theme navigation

Add an email link to your Shopify website from within your theme using your current link list in navigation.

How to flag Shopify products as "new" by date

Here's a quick way to mark a product as being new by the date it was added to your Shopify store.