Blog / Craft CMS

Craft CMS Listing All tags in your TWIG template

Alright, so you want to know how to print all tags from Craft CMS in a template, got it. Here's a step-by-step tutorial for ya:

Step 1: Open up your template where you want to display the tags.

Step 2: Find the section where you want to display the tags, this is usually in a loop that shows the entries or assets.

Step 3: Use the following code to display all tags associated with the entry or asset:

{% for tag in craft.tags().all() %}
    <a href="{{ url('/tags/'~tag.id) }}">{{ tag.title }}</a>
{% endfor %}

Step 4: Save your template and preview it on the front-end to see the tags displayed.

And that's it! Just remember to replace entry with asset if you're working with assets instead of entries. And if you want to style your tags or add some functionality you can always wrap them in html element or add some javascript to it.

Hope this helps, let me know if you have any questions.