Within my post, I have three tags in my front matter, I am trying to loop through these tags but it just puts all three of them mashed together in one string.
I am using this:
<tr>
{% for tag in post.tags %}
<td>{{ post.tag }}</td>
{% endfor %}
</tr>
I'd like an out of the box solution instead of relying on plugins but I am hosting my own so I am able to use them if I have to.
You are referencing page.tags
instead of just tag
in your loop. Use the following:
<tr>
{% for tag in page.tags %}
<td>{{ tag }}</td>
{% endfor %}
</tr>
Read more in the documentation.
Ok, I finally figured it out. This is not really covered in the documentation very well but makes ALL the difference. Jekyll supports BOTH tag: x, y, z
AND tags: x, y, z
- the s is very important. That changes whether or not jekyll will interpret multiple values or a single - the same problem can be found with category -> categories
in the front matter.
I likely missed it because I was using:
tag:
- x
- y
- z
Which is also supported but would not return string literal of "x, y, z" which might have ben a give away. Anyways, Thanks to rudolph9 for at least validating that my general direction was correct and for the syntax catch. I'm marking his as the right answer (cause I'm a nice guy) but you need to read this one as well to get the full learning McMeal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With