<p>As far as Craft is concerned whatever is in the <code>Entry URL Format</code> field is just another Twig snippet of code.  It gets rendered down super fast just like any other Twig code.  A few <code>if</code> conditionals aren't going to have any measurable impact on that process.</p>

CC BY-SA 3.0
2015-06-19T22:52:15.850Z
Thank you, Brad, that's good to know.  Also, [this answer](http://craftcms.stackexchange.com/questions/2459/url-format-of-a-nested-structure-with-3-or-more-layers) showed me that the conditionals are unnecessary for this. `{mainCategory.last().uri}/{postDate.year}/{slug}` is all I need to be able to handle any level of nested categories.
kr37
CC BY-SA 3.0
2015-06-20T04:17:57.070Z
Ahh, yeah... there's that, too. :)
Brad Bell
CC BY-SA 3.0
2015-06-19T22:13:43.973Z
2015-06-19T22:13:43.973Z
Brad Bell
<p>With help from <a href="https://craftcms.stackexchange.com/questions/1776/using-an-if-statement-to-define-the-entry-url-format">this answer</a>, I've got an Entry Url Format that can include top, 2nd, or 3rd-level categories.  It works for any of these situations:</p>

<pre><code>top-level-category/entry.slug
top-level-category/second-level-category/entry.slug
top-level-category/second-level-category/third-level-category/entry.slug

{% if object.mainCategory.last().level == 3 %}{mainCategory.last().parent.parent.slug}/{% endif %}{% if object.mainCategory.last().level &gt; 1 %}{mainCategory.last().parent.slug}/{% endif %}{mainCategory.last().slug}/{postDate.year}/{slug}
</code></pre>

<p>It's ugly, but it works. But I'm wondering if it is slowing things down a bit.  Does anyone have any knowledge in this area?</p>

<categories><url><conditional>
Performance hit from Entry Url Format with multiple {% if %} clauses?
# Performance hit from Entry Url Format with multiple {% if %} clauses?

(Asked by: username_0 on 2015-06-19)

With help from this answer, I've got an Entry Url Format that can include top, 2nd, or 3rd-level categories.  It works for any of these situations:
top-level-category/entry.slug
top-level-category/second-level-category/entry.slug
top-level-category/second-level-category/third-level-category/entry.slug

{% if object.mainCategory.last().level == 3 %}{mainCategory.last().parent.parent.slug}/{% endif %}{% if object.mainCategory.last().level > 1 %}{mainCategory.last().parent.slug}/{% endif %}{mainCategory.last().slug}/{postDate.year}/{slug}

It's ugly, but it works. But I'm wondering if it is slowing things down a bit.  Does anyone have any knowledge in this area?

**Tags:** categories, url, conditional

---

## 1 answers

### Answer by username_1 on 2015-06-19. Score: 3 | Accepted answer

As far as Craft is concerned whatever is in the `Entry URL Format` field is just another Twig snippet of code. It gets rendered down super fast just like any other Twig code. A few `if` conditionals aren't going to have any measurable impact on that process.

> **Comments:**
> **username_0**: Thank you, Brad, that's good to know.  Also, [this answer](http://craftcms.stackexchange.com/questions/2459/url-format-of-a-nested-structure-with-3-or-more-layers) showed me that the conditionals are unnecessary for this. `{mainCategory.last().uri}/{postDate.year}/{slug}` is all I need to be able to handle any level of nested categories.  
> **username_1**: Ahh, yeah... there's that, too. :)  

---

