Tagcloud and content page in GRAV

Below every post you see the result that comes from the tagcloud plugin.

In this post I will show what you do in the theme itself and how to make a page that receives the selected tag and show the posts.

In the theme itself to part where you show the tagcloud plugin content:

{% if grav.config.plugins.tagcloud.enabled %}
    <!-- tag plugin -->
    <h2 class="widget-title">{{ 'Popular Tags'|t }}</h2>
    {% include 'partials/tagcloud.html.twig' with {
       'config': grav.config
    } %}
{% endif %}

Notice: the with object is required, otherwise it won't see the ':' separator

I have created a table of contents page for categories and that is redirected to the home page (home page of this site).
In this template file I have added a mechanism to make it respond to tags as well.

{% extends 'docs.html.twig' %}
{% set tag = uri.param('tag')|defined(false) %}

{% block content %}

    {% if tag == false %}
        {% include 'partials/toc-chapter.html.twig' %}
    {% else %}
        {% include 'partials/toc-tag.html.twig' with {
            tag: tag
        } %}
    {% endif %}

{% endblock %}

IMPORTANT:

{% set tag = uri.param('tag')|defined(false) %}

partials/toc-tag.html.twig

<div id="body-inner">

    <div class="tag-content">
        <h2>Tag: {{ tag }}</h2>
        <ul>
            {% for post in taxonomy.findTaxonomy({
                'tag': tag
            }) %}

                <li class="tag">
                    <a href="{{ post.url }}">
                <span>
                    {{ post.title }}
                </span>
                    </a>
                </li>

            {% endfor %}
        </ul>
    </div>

    <!-- tagcloud also below this page -->
    {% if grav.config.plugins.tagcloud.enabled %}
        <!-- tag plugin -->
        <h2 class="widget-title">{{ 'Popular Tags'|t }}</h2>
        {% include 'partials/tagcloud.html.twig' with {
            'config': grav.config
        } %}
    {% endif %}

</div>
Last update: January 28th at 1:47pm