Answers.Body: <p>I'm not sure if this is a Craft 3 only issue. The following should work on Craft 2:</p>
  
  <p>Top-level Category: something/{slug}</p>
  
  <p>Nested Category: {parent.uri}/{slug}</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-15T13:02:30.150Z
Answers.Text: Thanks – I ended up making a top-level "Navigation" category group and then added all my categories under that. I then used a section with this Entry URI format: `{category.last().uri}/{parent.uri}/{slug}`.
Answers.UserDisplayName: Matt Andrews
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-15T02:43:18.950Z
Answers.LastActivityDate: 2017-09-15T02:43:18.950Z
Answers.UserDisplayName: idolab
Answers.Body: <p>You can use Twig logic in you <strong>Category URL Format</strong> like this:</p>
  
  <p><code>{parent ? parent.uri : group.handle }/{slug}</code></p>
  
  <p>This will prepend the category group's handle (main, about, funding, etc.) if it's a top-level category (no parent). Otherwise it prepends the parent category's full URI.</p>
  
  <p>Given you have a Category Group called <strong>"About"</strong> with the handle <strong>"about,"</strong> and that group has nested categories like this:</p>
  
  <pre><code>|-- cat-1
  |   |-- cat-1-1
  |   |-- cat-1-2
  |       |-- cat-1-2-1
  |
  |-- cat-2
  </code></pre>
  
  <p>You'll get URIs like this:</p>
  
  <pre><code>/about/cat-1
  /about/cat-1/cat-1-1
  /about/cat-1/cat-1-2
  /about/cat-1/cat-1-2/cat-1-2-1
  /about/cat-2
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-11T19:05:03.733Z
Answers.LastActivityDate: 2018-10-11T19:05:03.733Z
Answers.UserDisplayName: Alex Roper
Answers.Body: <p>You would just enter <code>{ parent? parent.slug : '' }/{ slug }</code> in the "Category URI Format" Field in the Craft3 CP and it will recognize nested categories</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-21T18:18:21.147Z
Answers.LastActivityDate: 2018-05-21T18:18:21.147Z
Answers.UserDisplayName: EDub
Body: <p>I've <a href="https://craftcms.stackexchange.com/questions/20800/nested-categories-in-url-slug">asked already</a> about nested categories here, but I've just upgraded to Craft 3 and things seem to have changed a little.</p>
  
  <p>I have three top-level category groups:</p>
  
  <pre><code>- Home
  - About
  - Funding
  </code></pre>
  
  <p>Each of these has multiple categories, and some of these categories are nested up to three levels deep.</p>
  
  <p>My problem: the nested category URIs don't include the category group (which I appreciate doesn't have its own slug). Instead I get stuff like this:</p>
  
  <pre><code>/cat-A/subcat-1/
  /cat-B/subcat-2/subcat-6/
  </code></pre>
  
  <p>... when what I want is:</p>
  
  <pre><code>about/cat-A/subcat-1/
  funding/cat-B/subcat-2/subcat-6/
  </code></pre>
  
  <p>If I manually add <code>funding/</code> or <code>about/</code> as part of those categories' URI formats (eg. <code>funding/{parent.uri}/{slug}</code>) then it appends <code>funding/</code> at each level, eg: <code>funding/funding/funding/cat-B/subcat-2/subcat-6</code>. </p>
  
  <p>I've managed to achieve what I want for <em>entries</em>, by setting their URI format like so: </p>
  
  <pre><code>{category.first().group.handle}/{category.last().uri}/{parent.uri}/{slug}
  </code></pre>
  
  <p>... which gives me stuff like:</p>
  
  <pre><code>funding/cat-B/subcat-2/subcat-6/entry-title-slug
  </code></pre>
  
  <p>I only really need this feature to work because I envision users browsing the categories and potentially clicking the URI/links and being taken to the wrong place.</p>
  
  <p>In my earlier post I created a top-level category group called "Navigation" which contained all my categories – this achieved the correct URIs. This feels messy/hacky though and means my users have to see a redundant "Navigation" group when editing categories.</p>
  
  <p>It's likely I'm misunderstanding some aspect of Craft here – can anyone help me achieve what I'm trying to do here?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-14T15:43:08.413Z
Comments.Text: I can't tell... is this specific to Craft 3 or do you have the same issue on Craft 2?
Comments.UserDisplayName: Brad Bell
Tags: <craft3>
Title: Including the category group in nested category URIs?
ThreadText: # Including the category group in nested category URIs?
  
  (Asked by: username_0 on 2017-09-14)
  
  I've [asked already](https://craftcms.stackexchange.com/questions/20800/nested-categories-in-url-slug) about nested categories here, but I've just upgraded to Craft 3 and things seem to have changed a little.
  
  I have three top-level category groups:
  
  ```
  - Home
  - About
  - Funding
  
  ```
  
  Each of these has multiple categories, and some of these categories are nested up to three levels deep.
  
  My problem: the nested category URIs don't include the category group (which I appreciate doesn't have its own slug). Instead I get stuff like this:
  
  ```
  /cat-A/subcat-1/
  /cat-B/subcat-2/subcat-6/
  
  ```
  
  ... when what I want is:
  
  ```
  about/cat-A/subcat-1/
  funding/cat-B/subcat-2/subcat-6/
  
  ```
  
  If I manually add `funding/` or `about/` as part of those categories' URI formats (eg. `funding/{parent.uri}/{slug}`) then it appends `funding/` at each level, eg: `funding/funding/funding/cat-B/subcat-2/subcat-6`.
  
  I've managed to achieve what I want for *entries*, by setting their URI format like so:
  
  ```
  {category.first().group.handle}/{category.last().uri}/{parent.uri}/{slug}
  
  ```
  
  ... which gives me stuff like:
  
  ```
  funding/cat-B/subcat-2/subcat-6/entry-title-slug
  
  ```
  
  I only really need this feature to work because I envision users browsing the categories and potentially clicking the URI/links and being taken to the wrong place.
  
  In my earlier post I created a top-level category group called "Navigation" which contained all my categories – this achieved the correct URIs. This feels messy/hacky though and means my users have to see a redundant "Navigation" group when editing categories.
  
  It's likely I'm misunderstanding some aspect of Craft here – can anyone help me achieve what I'm trying to do here?
  
  **Tags:** craft3
  
  > **Comments:**
  > **username_1**: I can't tell... is this specific to Craft 3 or do you have the same issue on Craft 2?  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2017-09-15. Score: 1 | Accepted answer
  
  I'm not sure if this is a Craft 3 only issue. The following should work on Craft 2:
  
  Top-level Category: something/{slug}
  
  Nested Category: {parent.uri}/{slug}
  
  > **Comments:**
  > **username_0**: Thanks – I ended up making a top-level "Navigation" category group and then added all my categories under that. I then used a section with this Entry URI format: `{category.last().uri}/{parent.uri}/{slug}`.  
  
  ---
  
  ### Answer by username_3 on 2018-10-11. Score: 2
  
  You can use Twig logic in you **Category URL Format** like this:
  
  `{parent ? parent.uri : group.handle }/{slug}`
  
  This will prepend the category group's handle (main, about, funding, etc.) if it's a top-level category (no parent). Otherwise it prepends the parent category's full URI.
  
  Given you have a Category Group called **"About"** with the handle **"about,"** and that group has nested categories like this:
  
  ```
  |-- cat-1
  |   |-- cat-1-1
  |   |-- cat-1-2
  |       |-- cat-1-2-1
  |
  |-- cat-2
  
  ```
  
  You'll get URIs like this:
  
  ```
  /about/cat-1
  /about/cat-1/cat-1-1
  /about/cat-1/cat-1-2
  /about/cat-1/cat-1-2/cat-1-2-1
  /about/cat-2
  
  ```
  
  
  ---
  
  ### Answer by username_4 on 2018-05-21. Score: 2
  
  You would just enter `{ parent? parent.slug : '' }/{ slug }` in the "Category URI Format" Field in the Craft3 CP and it will recognize nested categories
  
  
  ---
  
  