Kurt Emch
Kurt Emch

Reputation: 529

Using replace filter mangles jekyll site.tags

I'm having a problem controlling the appearance of my site's tags when using a for loop to render out all tags in site.tags.

This is what I am intending:

<li class="sliced-almonds">sliced almonds</li>

And this is what I have:

{% for tag in site.tags %}
    <li class="{{ tag | handleize | replace:' ','-' }}">{{ tag }}</li>
{% endfor %}

But instead I get this:

<li class="[" sliced-almonds",-[<post:-="" salads="" salad-04="">]]"&gt;sliced almonds</li>

Upvotes: 4

Views: 1351

Answers (1)

Kurt Emch
Kurt Emch

Reputation: 529

Just figured it out. When using grabbing tags from site.tags, tag[0] is the name and tag[1] are all of the posts associated with that tag.

<ul>
    {% for tag in site.tags %}
    <li class="{{ tag[0]  | replace:' ','-' }}">{{ tag }}</li>
    {% endfor %}
</ul>

Upvotes: 5

Related Questions