Represents single tag associated with article. Tags for given article can be rendered by going through list of tags:
For editing in article:
{% if editmode %}
{% editable article.tags %}
{% else %}
{% for tag in article.tags %}
{{ tag.name }}
{% endfor %}
{% endif %}
By combining filters, there are shortcuts to render the list of tag names:
{{ article.tags | sort: "name" | map: "name" | join: ", " }}
For getting all site tags and generating tag clouds look at site object.
Returns name of the tag.
Returns path of the tag for generating URLs.
Example of generating tag list next to article that links to blog page with articles filtered out with given tags:
{% for tag in article.tags %}
<a href="/{{ article.page.path_with_lang }}/tagged/{{ tag.path }}">{{ tag.name }}</a>
{% endfor %}
On blog listing page an object name tags is present and if blog listing page is displayed with tag filter this returns the filter of tags.
{% if tags %}
{% if tags == empty %}
{{ "no_posts_tagged" | lc }}
{% else %}
{{ "posts_tagged" | lc }} '{{ tags | sort: "name" | map: "name" | join: "', '"}}'.
{% endif %}
{% endif %}
Example of generating links of blog related tags on blog listing page and matching with tags in filter that are actively selected:{% if blog.has_tags? %}
{% comment %}Get the names of selected tag filters to an array.{% endcomment %}
{% if tags %}
{% assign selected_tags = tags | map: "name" %}
{% endif %}
{% comment %}Render list of links to tags in blog. Display active class if matches an active tag filter{% endcomment %}
{% for tag in blog.tags %}
<a {% if selected_tags contains tag.name %}class="active"{% endif %} href="/{{ blog.page.path_with_lang }}/tagged/{{ tag.path }}">{{ tag.name }}</a>
{% endfor %}
{% endif %}