Tag Cloud plugin won't filter

I can’t seem to get the Tag Cloud plugin to work. It correctly generates a tag cloud in my sidebar, but when I click one of those tags it just goes to the homepage. I’m expecting a page that lists (filters) all the pages with that tag. Am I missing something?

@skipper, Template partials/tagcloud.html.twig from TagCloud uses variable base_url to create the url of the blog:

<a href="{{ base_url }}/tag{{ config.system.param_sep }}{{ tax|e('url') }}">{{ tax }}</a>

If the variable is not set, the link will point to the home page. That will not be a problem if the blog is itself the home page.

If the blog page is not the home page, you need to pass the value for base_url into the template of TagCloud.

{% include 'partials/tagcloud.html.twig' with { 'base_url': '/blog'} %}

Some themes, like Quark, create a variable that contains the blog page, which can be used to get the url of the blog page. In that case you can pass that url into the included template:

{% set new_base_url = blog.url == '/' ? '' : blog.url %}
...
{% include 'partials/tagcloud.html.twig' with { 'base_url': new_base_url } %}
1 Like

@pamtbaau, thanks. I can change the base_url to something other than the homepage, but I’m still getting a blank page… no results. Nothing filtered. I tried changing the template I’m using and that didn’t solve it. What am I doing wrong here?

@skipper,

What am I doing wrong here?

Without providing any relevant information there is not much else the community can do for you apart from guessing…

Please help the community help you by creating clear questions. The less time one spends on the question, the more time others need to spend on answers…

Well, I’m not sure how the Tag Cloud results page is supposed to work or look like, but I got it working by modifying the taxonomy example from the docs. I got the tag value from the uri and used that to get my list of pages with that tag. Again, I’m not sure how this is supposed to work but here’s what I did:

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

<h2>{{param}} Posts</h2>
<ul>
{% for post in taxonomy.findTaxonomy({'tag':param}) %}
    <li><a href="{{ post.url }}">{{ post.title|e }}</a></li>
{% endfor %}
</ul>