How to check url will be unique when removing parent page slug

I have a multilanguage site. To avoid putting all article pages under one content folder I thought of using the below setup:

index
  - blog
     - interviews
         - article
     - podcasts
         - article
     - bulletins
         - article

I would like to remove the parent page slug (“interviews”, “podcasts” or “bulletins”) using the route method so that:

domain.com/blog/interviews/article becomes domain.com/blog/article

In the creation of each new “article” is there a way to check that it is a unique slug? I ask this because of the off chance the editors create an article with the same title in two different categories.

Thank you!

You could do that via a page.create:before hook.

Why? Because there will be many in the long run?

There is approx 500 articles now, and will be about 1000 in a few years.

I don’t need to query them that much, but on the blog page I need to organise them by category, eg. all Interviews, all podcasts.

I don’t think it will be too resource heavy, but wanted to avoid bottlenecks. But perhaps with cache it will be fine?

That would also be possible if you add the categories via a field. Not sure what I’d do myself in this case, I’d probably put them all into one folder, particularly if I don’t want the subpages in the URL. In case it causes performance issues in the future, it will be easy to change the setup and move the pages into category folders programmatically.

Thanks, I too think this is a good initial approach.