I would like to create to separate Jekyll includes that can both reference the same common variable. Here is a simplified scenario.
I create _include/setter.html
with the following Liquid code:
{% globalString | append: include.add | append: "," %}
Then I create _include/getter.html
with the following Liquid code:
we have {{ globalString }}
Then in my page I put:
{% include setter.html add = "one" %}
{% include setter.html add = "two" %}
{% include getter.html %}
I'd like to see a result something like we have one,two,
as a result.
But of course globalString
does not exist, so this cannot work. I can't seem to create new variables in site
or page
that can be seen from includes. For now I am awkwardly working around this with capture
. Is there a better way to pass data out of an include in Jekyll?