I have a page that displays entries based on a specific tag. It works well until I apply the kebab filter.

Here's my link to the page:

{% for tag in tag %}
    <li><a href="{{ siteUrl }}tags/{{ tag.title | kebab}}">{{ tag.title }}</a></li>
{% endfor %}

and my tags/tag.html page looks like this:

{% set tag = craft.tags.name(tag).first() %}
{% set entries = craft.entries.relatedTo(tag).order('title') %}
{% if entries | length %}
   {% for entry in entries %}
       Code here
    {% endfor %}
{% endif %}

The page populates all entries regardless of the tag once I apply the kebab filter. How can I fix that?

Thanks in advance.

1 Answer 1


For your link, change {{ tag.title | kebab}} to {{ tag.slug }}

Then on your tag.html page change your tag variable to this:

{% set tag = craft.tags.slug( craft.request.segment(2) ).first() %}

This is how I have it set up and works fine.

Edit: Forgot the route needed: Add this to your routes.php: 'tags/{slug}' => 'tags/tag',


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.