Answers.Body: <p>You should be able to set your Category URI Format to <code>{parent.slug}/{slug}</code></p>
  
  <p>If they are on the parent it will only show the parent category. If they are on the child it will show both.</p>
  
  <p>So you'd set it to</p>
  
  <pre><code>what-we-do/{parent.slug}/{slug}
  </code></pre>
  
  <p>There is also this answer if you need the path beyond 1 level:</p>
  
  <p><a href="https://craftcms.stackexchange.com/questions/23610/parent-uri-slug?rq=1">{parent.uri}/{slug}</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-11T18:14:41.970Z
Answers.Text: If you do that Darryl you end up with tld.com/what-we-do/what-we-do/category-parent/category-child.
Answers.UserDisplayName: Michael Thomas
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-11T16:32:32.913Z
Answers.LastActivityDate: 2018-10-11T16:42:31.897Z
Answers.LastEditDate: 2018-10-11T16:42:31.897Z
Answers.UserDisplayName: Darryl Hardin
Answers.Body: <p>You can actually use a bit of Twig logic to determine your category URI formats.</p>
  
  <p>Try this for your <strong>Category URI Format</strong>:</p>
  
  <p><code>{parent ? parent.uri : 'what-we-do'}/{slug}</code></p>
  
  <p>Which is just a more compact way of doing this:</p>
  
  <pre><code>{% if parent %}{{ parent.uri }}{% else %}what-we-do{% endif %}/{slug}
  </code></pre>
  
  <p>That will only add 'what-we-do' to the URI if the current category doesn't have a parent (top-level category). Otherwise, it prepends the entire parent's URI.</p>
  
  <p>That should give you URIs like:</p>
  
  <pre><code>/what-we-do/service-one
  /what-we-do/service-one/subservice-one-a
  /what-we-do/service-one/subservice-one-b
  /what-we-do/service-one/subservice-one-b/subservice-one-b-nested
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-11T18:20:32.270Z
Answers.LastActivityDate: 2018-10-15T04:52:57.523Z
Answers.LastEditDate: 2018-10-15T04:52:57.523Z
Answers.UserDisplayName: Alex Roper
Body: <p>I am trying to set up the URIs for some nested categories in Craft 3 but am having some issues. My structure is basically:</p>
  
  <pre><code>service-one
  |-subservice-one-a
  |-subservice-one-b
  service-two
  |-subservice-two-a
  |-subservice-two-b
  </code></pre>
  
  <p>I have set my <code>Category URI Format</code> to:</p>
  
  <p><code>what-we-do/{slug}</code></p>
  
  <p>Which is working fine, however I would like the URI for the nested categories to look like:</p>
  
  <p><code>what-we-do/service-one/subservice-one-a</code></p>
  
  <p>rather than what I have currently:</p>
  
  <p><code>what-we-do/subservice-one-a</code></p>
  
  <p>Is this possible?</p>
  
Tags: <craft3><categories>
Title: URI for nested categories in Craft 3
ThreadText: # URI for nested categories in Craft 3
  
  (Asked by: username_0 on 2018-10-11)
  
  I am trying to set up the URIs for some nested categories in Craft 3 but am having some issues. My structure is basically:
  
  ```
  service-one
  |-subservice-one-a
  |-subservice-one-b
  service-two
  |-subservice-two-a
  |-subservice-two-b
  
  ```
  
  I have set my `Category URI Format` to:
  
  `what-we-do/{slug}`
  
  Which is working fine, however I would like the URI for the nested categories to look like:
  
  `what-we-do/service-one/subservice-one-a`
  
  rather than what I have currently:
  
  `what-we-do/subservice-one-a`
  
  Is this possible?
  
  **Tags:** craft3, categories
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2018-10-11. Score: 10 | Accepted answer
  
  You can actually use a bit of Twig logic to determine your category URI formats.
  
  Try this for your **Category URI Format**:
  
  `{parent ? parent.uri : 'what-we-do'}/{slug}`
  
  Which is just a more compact way of doing this:
  
  ```
  {% if parent %}{{ parent.uri }}{% else %}what-we-do{% endif %}/{slug}
  
  ```
  
  That will only add 'what-we-do' to the URI if the current category doesn't have a parent (top-level category). Otherwise, it prepends the entire parent's URI.
  
  That should give you URIs like:
  
  ```
  /what-we-do/service-one
  /what-we-do/service-one/subservice-one-a
  /what-we-do/service-one/subservice-one-b
  /what-we-do/service-one/subservice-one-b/subservice-one-b-nested
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2018-10-11. Score: 2
  
  You should be able to set your Category URI Format to `{parent.slug}/{slug}`
  
  If they are on the parent it will only show the parent category. If they are on the child it will show both.
  
  So you'd set it to
  
  ```
  what-we-do/{parent.slug}/{slug}
  
  ```
  
  There is also this answer if you need the path beyond 1 level:
  
  [{parent.uri}/{slug}](https://craftcms.stackexchange.com/questions/23610/parent-uri-slug?rq=1)
  
  > **Comments:**
  > **username_2**: If you do that username_1 you end up with tld.com/what-we-do/what-we-do/category-parent/category-child.  
  
  ---
  
  