[SOLVED] Front matter array with multiple values

Hello, it’s my first time with Jekyll and Liquid, and fortunately, I’ve easily managed to build my project. But there are a couple issues I couldn’t overcome with the information provided in Jekyll documentation.

I have a single collection for which I have 3 different custom front matter items. I’ve set up the collection, sorted them successfully using “where” argument, and have them working just fine. But I can’t have more than one value for each front matter string, such as

---
layout: default
x: a
y: b
z: c d e
---

I’ve tried space-separated, comma-separated and YAML lists, but none of them worked. “c d e” is rendered as a single value, instead of 3 separate values. Where do I go wrong? :confused:

Thanks, regards!

Could be a YAML thing. To do an array try:

z: [c, d, e]

ref: https://rollout.io/blog/yaml-tutorial-everything-you-need-get-started/

You can specify arrays or lists on a single line.

items: [ 1, 2, 3, 4, 5 ]
names: [ "one", "two", "three", "four" ]

Or, you can put them on multiple lines.

items:
  - 1 
  - 2 
  - 3
  - 4 
  - 5 
names:
  - "one"
  - "two"
  - "three"
  - "four"

The multiple line format is useful for lists that contain complex objects instead of scalars.

items:
  - things:
      thing1: huey
      things2: dewey
      thing3: louie
  - other things:
      key: value

An array can contain any valid YAML value. The values in a list do not have to be the same type.

4 Likes