Get category title by slug I'm setting my categories by matching the third segment to a category slug. How do I get the category title?

{% set catSlug = craft.request.getSegment(3) %}
{% set category = craft.categories.slug(catSlug) %}


{{ category.slug }} returns the slug, but {{ category.title }} returns nothing.
You need to add .first() when setting the category. As far as I can tell, if you don't have .first() only {{ category.slug }} will work.

First get the slug:


{% set catSlug = craft.request.getSegment(3) %}


This will give you the CategoryModel object for catSlug:

{% set category = craft.categories.slug(catSlug).first() %}


You can now access whatever you want from the category, like the title:

{{ category.title }}