1

Again, I've had a look online but couldn't figure out what I had to do.

Say I've got a category structure like the below:

  • Category 1
    • Saturday
    • Sunday
  • Category 2
    • Saturday
    • Sunday

How can I allow duplicate category slugs so that they can be like:

/category-1/saturday/*
/category-2/saturday/*

Instead of:

/category-1/saturday/*
/category-2/saturday-1/*

What I have found online talks about Entries and Routes and then setting it up do serve from specific template but I'm not really sure where to start with that as still trying to learn how to work with Craft.

For example, this answer mentions how it should be possible if the Entry URI Format has been set up correctly for Sections but I haven't set up sections for creating categories so I'm not sure how my case relates (if it's of any use, I embed a screenshot of what I am referring to and category structure below):

Craft CMS Category Structure

Is there not a simple way to just achieve duplicate slugs for categories as per my above example?

If I try changing the slug to say 'saturday', it just re-appends the -1 to the end again.

2

Jamie's answer is correct.

If you set your Settings → Categories → Category URI Format to {parent.uri}/{slug} you will then be able have multiple time the same slug.

Craft will take the parent into consideration when saving the category therefore allowing you to have (in your case) byc/saturday and wbr/saturday

|improve this answer|||||
  • Excellent, this was what I was after. I actually found that by inserting the category group though, {parent.uri}/{slug} caused this to duplicate when a sub-category existed but by using {parent ? parent.uri : group.handle }/{slug} with the help of this answer, it got it perfect but your answer was exactly what was needed to ensure duplicate slugs could be used - thanks :) – zigojacko Nov 27 '19 at 10:56

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.