Remove "Category" from URL

Hi together,

I need some hint, how I can solve this little problem. I have a page template which is only used as a category headline inside a mega menu. With that I can edit and manage the categories and all the pages “inside”. This actaully works fine. The category-pages themselves have no output.

But now I have long urls of the pages and I want to delete those categories/headlines from the url. I also have multiple levels of pages.

/level-1/level-2 → fine
/level-1/level-2/level-3 → fine

/level-1/category-1-level-2/level3 → /level-1/level-3
/level-1/category-2-level-2/level3 → /level-1/level-3
/level-1/category-2-level-2/level3/level4 → /level-1/level-3/level-4

I hope you understand my issue. How would you do this? I’m searching for a solution for kirby 3.4 and which works generally for all kind of categorie and page titles – if possible.

I already found this topic, but It’s not really the same.

THX

This would be the go to docs: Routes | Kirby CMS

With the difference that you want to remove the middle part, so you need to adapt that a bit.