Jekyll and Hash Arrays
Having just once again suffered through the dimly remembered pain
of learning about Jekyll, Liquid, and hash arrays, I am recording it
here to save myself the next time I go for a few years between
dealing with it. Official documentation does not say this
(enough?), I guess because they think, "They can't, so let's not
bother talking about it." This leaves the experienced programmer
new to Liquid going "I should be able to do this, why can't I
just assign myHash = { one: 1, two: 2 }
or
["one" => "1", "two" => "2"]
or some combination of
braces and quotes or other punctuation? Do I just have the syntax
wrong???"
You can't. For some reason
"they" don't want you to. So, define your hash array in the
page _layout
front matter,
site _config.yml
, or site _data/
if what
you really want is to put it in the front matter of
an _include
(because there's no front matter for
includes).
- Hash arrays cannot be created within
Jekyll+Liquid
- vector arrays can
- hash arrays can be created in front matter
or
.yml
files