<p>To pull off the same functionality in Craft 3, you could use something like this:</p>

<pre><code>{entry.last().uri}/{parent.uri}/{slug}
</code></pre>

CC BY-SA 3.0
2018-01-26T02:08:22.903Z
Awesome, thanks Brad. Might be worth somehow including this in the CP field instructions for a structure or elsewhere in the craft doco as I would assume most people would want this format for a structure section. :)
Rich Hayler
CC BY-SA 3.0
2018-01-28T07:23:55.130Z
I ended up using the following: `{% if level == 1 %}{section.handle}{% else %}{parent.uri}{% endif %}/{slug}`
Rich Hayler
CC BY-SA 4.0
2019-01-29T22:59:14.523Z
the accepted answer turned out faulty on my craft 3 version. I ended up using `{parent.uri ?? 'top-level'}/{slug}` and solved my issue of duplicated segments while allowing for a fixed segment. The solution of Rich could be rewritten as `{parent.uri ?? section.handle}/{slug}` for readability purposes
3xil3
CC BY-SA 4.0
2019-04-04T04:14:09.240Z
3xil3 has the correct answer.
biko
CC BY-SA 4.0
2019-09-22T15:22:30.430Z
After trying all answers here and at the related question here: https://craftcms.stackexchange.com/q/26483/4060 , the only answer that seems to allow for a static, non-duplicated segment in the url is here: https://craftcms.stackexchange.com/a/26484/4060
Tchick
CC BY-SA 4.0
2021-04-29T19:12:34.347Z
This seems to be very complicated for what would ideally be a fairly mundane setting, coming back to Craft after a few months off I'm quite confused as to how to get this working at all!
James Greig
CC BY-SA 3.0
2018-01-24T22:37:05.927Z
2018-01-24T22:37:05.927Z
Brad Bell
<p>In Craft 2.x you have the option of setting the top-level entries URL format for a structure section separately from nested entries i.e. <code>top-level/{slug}</code> and <code>{parent.uri}/{slug}</code></p>

<p>But in Craft 3 the same URL format is applied for all entries within the structure section.</p>

<p>This means if you use <code>top-level/{parent.uri}/{slug}</code> it works fine for a top-level entry but then nested entries have the first segment duplicated, e.g. top-level/top-level/some-parent/the-slug. How does one achieve the same level of URL formatting for structure entries in Craft 3?</p>

CC BY-SA 4.0
2018-08-02T19:30:29.660Z
This worked for me...
https://craftcms.stackexchange.com/questions/26483/nested-entries-in-craft-3?newreg=dc9615a7c8bd4bac9fd5208438927108
user303199
<control-panel><craft3>
{parent.uri}/{slug}
# {parent.uri}/{slug}

(Asked by: username_0 on 2018-01-24)

In Craft 2.x you have the option of setting the top-level entries URL format for a structure section separately from nested entries i.e. `top-level/{slug}` and `{parent.uri}/{slug}`

But in Craft 3 the same URL format is applied for all entries within the structure section.

This means if you use `top-level/{parent.uri}/{slug}` it works fine for a top-level entry but then nested entries have the first segment duplicated, e.g. top-level/top-level/some-parent/the-slug. How does one achieve the same level of URL formatting for structure entries in Craft 3?

**Tags:** control-panel, craft3

> **Comments:**
> **username_1**: This worked for me... https://craftcms.stackexchange.com/questions/26483/nested-entries-in-craft-3?newreg=dc9615a7c8bd4bac9fd5208438927108  

---

## 1 answers

### Answer by username_2 on 2018-01-24. Score: 20 | Accepted answer

To pull off the same functionality in Craft 3, you could use something like this:
{entry.last().uri}/{parent.uri}/{slug}

> **Comments:**
> **username_0**: Awesome, thanks Brad. Might be worth somehow including this in the CP field instructions for a structure or elsewhere in the craft doco as I would assume most people would want this format for a structure section. :)  
> **username_0**: I ended up using the following: `{% if level == 1 %}{section.handle}{% else %}{parent.uri}{% endif %}/{slug}`  
> **username_3**: the accepted answer turned out faulty on my craft 3 version. I ended up using `{parent.uri ?? 'top-level'}/{slug}` and solved my issue of duplicated segments while allowing for a fixed segment. The solution of Rich could be rewritten as `{parent.uri ?? section.handle}/{slug}` for readability purposes  
> **username_4**: username_3 has the correct answer.  
> **username_5**: After trying all answers here and at the related question here: https://craftcms.stackexchange.com/q/26483/4060 , the only answer that seems to allow for a static, non-duplicated segment in the url is here: https://craftcms.stackexchange.com/a/26484/4060  
> **username_6**: This seems to be very complicated for what would ideally be a fairly mundane setting, coming back to Craft after a few months off I'm quite confused as to how to get this working at all!  

---

