Using jekyll site.tags filter replacements

I had a problem controlling the appearance of tags on my site when using a for loop to display everything tagsin site.tags.

This is what I intend:

<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 the following:

<li class="[" sliced-almonds",-[<post:-="" salads="" salad-04="">]]"&gt;sliced almonds</li>
+4
source share
1 answer

Just figured it out. When using capturing tags from site.tags, tag[0]is the name and tag[1]is all messages associated with this tag.

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

Source: https://habr.com/ru/post/1532391/


All Articles