Home > Shopify Development > Liquid split: How to Divide String into Array

Liquid split: How to Divide String into Array in Shopify

Sam Nguyen
Sam Updated: May 07, 2024


Drive 20-40% of your revenue with Avada
avada email marketing

Although Liquid has just been launched as a product of Shopify since 2006, this tool is getting more and more popular for the Shopify store owners. Now Liquid plays an important role in Shopify as well as many other web applications. Considered as an open-source template language, Liquid provides the helpful functionality to build up a theme, which contributes effectively to their Shopify shops.

There are three kinds of Liquid codes such as objects, tags, and filters. Particularly, Liquid filters which helps the web developers to change the Liquid object’s output. The users can use multiple filters within an output. In the output, the Liquid filters are separated by a | from left to right.

Split an input string is using the argument, which divides the title into multiple lines. Through this article Liquid split: How to Divide String into Array in Shopify, we hope that online merchants can use the below guides to convert comma-separated items from input to their expected array by themselves.

How to Divide String into Array in Shopify

About Array

Besides, online sellers also have to know about Arrays- a list of multiple variables. However, it is impossible for the Shopify store owners to initialize arrays just only by Liquid. Instead of using Liquid, they should split filter. By breaking a string, the web developers can have arrays of substrings. As a delimiter, the substring is useful for the store owners to divide a string into an array. Furthermore, with the array filters, the output can be different parts of an array.

The way to divide string into array

Step 1: Input

At the first step, it is necessary for the Shopify store owners to log in their Shopify account. In the admin dashboard, they find these lines {% assign beatles %} in the theme. In this example, we have the title "John, Paul, George, Ringo" To continue, they can enter those following input.


{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}

{% for the member in beatles %}
  {{ member }}
{% endfor %}

Step 2: Output

The result of that input, the string will be split into multiple lines like that : Output






With the simple process in this article Liquid split: How to Divide String into Array in Shopify, the Shopify store owners can divide their string into expected lines. Moreover, online sellers can discover more about Liquidity and another topic with our guiding blogs. There are some relevant articles that you can refer to:

Sam Nguyen is the CEO and founder of Avada Commerce, an e-commerce solution provider headquartered in Singapore. He is an expert on the Shopify e-commerce platform for online stores and retail point-of-sale systems. Sam loves talking about e-commerce and he aims to help over a million online businesses grow and thrive.

Stay in the know

Get special offers on the latest news from AVADA.