1

Basic info

  • I have a structure with a handle about.
  • The Entry URI format is about/{slug}. EDIT: also tried it with just {{ slug }}
  • I created a child page called "Privacy Policy" with the slug privacy-policy. It has a parent of the page "About SAFS" (slug about-safs).
  • I can only access the page at mysite.com/about/about-safsprivacy-policy. If I go to mysite.com/about/privacy-policy, I get a 404.
  • If I include {{ entry.slug }} in the template, it prints privacy-policy.

Edit: This is my Settings > Sections > About after changing slug to just { slug } enter image description here

My question

Why is the parent's slug being inserted into the URI, and how do I change that?


Possibly relevant info

All the top-level pages in the About structure display on a single page, using this template for the entries:

{% if entry.level == 1 %}
  {% redirect siteUrl|trim ~ 'about#' ~ entry.slug %}
{% else %}

  {# normal template #}

For the About index template, I include:

{% set link = siteUrl ~ "/about" %}

EDIT: I also tried removing the redirect from the template, and I'm getting the same routing issue for the privacy-policy entry.

3

Pretty sure that the ResaveElements task just hadn't run yet - my queue was stuck. Once I cleared the stuck items, the issue resolved on its own!

1

Please take a look into your section. In Craft 2 there are two fields: Uri format parent and URI format child. You probably included the parent slug into the child input

Additional note: it's not a good way to rebuild your links manually. You should always use the getUrl() function unless you have a really good reason for it

  • Thanks for the quick response, Robin! Could you explain it more for me, or maybe in different words? - I'm using Craft 3, not Craft 2. - What do you mean by URI format parent and URI format child? Is that somewhere in the docs you could point me to? - If I'm putting the slug in the wrong, place, what is the right place? Thanks in advance! – Katie Fritz Apr 14 '18 at 21:14
  • You have two inputs in your section settings. One contains the url format for your first level entries (the parent) one input is for the child url format. When you say your child url format contains the parent slug that's usually because your input field looks like {parent.slug}{slug} or something like that. Remove the {parent.slug} part and it should be fine. Because you said "the entry uri format is about/{slug}" you looked only at the first level uri, not at the field next to it – Robin Schambach Apr 14 '18 at 21:17
  • Thanks! I just added a screenshot of my section settings to my original post. I only see one option for adding a URL format. Is there another place I should be looking? – Katie Fritz Apr 14 '18 at 21:22
  • Ah no, I just didn't realize it was about Craft 3. Craft 3 removed the 2nd field and combined them into one. When you take a look at your entry list in your cp and include the URL column to the table, is the format correct? – Robin Schambach Apr 14 '18 at 21:25
  • So, weird things happening. I've set the Entry URI format to just be {{ slug }}, and removed the conditional logic/redirects from my template for testing. When I create a new page in this section (level 1), the URL is just mysite.com/slug. For my old pages, it's mysite.com/about/slug. – Katie Fritz Apr 14 '18 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.