I have a Category Group that can be 3 levels deep. Each category has its own page and its URI structure appends each category as you go deeper, like so:

{parent ? parent.uri : 'root-uri' }/{slug}

Which produces:


This all works fine.

I then have a field to assign these categories to an entry. My goal is to create a URI format for the entries that include the hierarchy of the categories it's assigned to. Like:




What is the proper URI format for the entries to accomplish this?


Using {categoriesField.last().uri}/{slug} is working, but the .last() function is deprecated.

2 Answers 2


The URL format can be a full-blown twig template, so you can use a regular category query to retrieve the category. To replace the deprecated last() method, you can use leaves() to narrow the category query to only return leaf nodes (categories with no descendants), then use one() to return the first matching result:

{{ object.categoriesField.leaves().one().uri ?? '' }}/{{ object.slug }}

Since last() is deprecated, here is the updated version that works:


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.