The official doc of Liquid doesn’t tell us a way to create an array except this:
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
{% for member in beatles %}
{{ member }}
{% endfor %}
But what if you want to create an array of objects? Well, there’s a trick. First, create an empty array
using split
and then add your object to the array using push
.
{% assign posts = "" | split: "," %}
{% assign posts = posts | push: post %}