I use the code "Link to the Tag URLs" from the following article: https://craftcms.com/support/tag-urls

{% if entry.tags | length %}
<h3>This entry is tagged with:</h3>

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

One thing is that the "url_encode" doesnt really apply as if I expected. The URL looks like this: http://domain.dev/tags/My%20Tag%20Name

But when I click on it, there are still spaces in the address line.

So my question is: is that ok like this?

I was also thinking about using the kebab filter. There I receive this url: http://domain.dev/tags/my-tag-name

which looks prettier. But I now I get an error with the routing when I want fetch the tag:

{% set tag = craft.tags.title(tag).first() %}

1 Answer 1


This post helped me with my issue with a different approach (except of using the kebab filter the slug of the tag is used for the route)

Use of tag.slug instead of tag.title in a custom route

as I think that makes lot more sense then using the title, maybe it would be a good idea to update the article in the support section of the craftcms website.

  • +100 on updating the article in the support section. I think that article predates the existance of tag.slug Commented Oct 1, 2017 at 14:53

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.