Skip directory from URL, but keep it in side the filesystem

I have a directory structure that looks like this:

  • 1-folderA
    • 1-subFolderA1
    • 2-subFolderA2
  • 2-folderB
    • 1-subFolderB1
    • 2-subFolderB2

I’m looping through the page children to build a menu like this:

<ol>
    <li>
        <strong>folderA</strong>
        <ol>
            <li><a href="subFolderA1">subFolderA1</a></li>
            <li><a href="subFolderA2">subFolderA2</a></li>
        </ol>
    </li>
    <li>
        <strong>folderB</strong>
        <ol>
            <li><a href="subFolderB1">subFolderB1</a></li>
            <li><a href="subFolderB2">subFolderB2</a></li>
        </ol>
    </li>
</ol>

As you can see I would like to skip the top directories from appearing inside the URL, but still be able to order them.

I though it could work with hiding the page, but hiding seems to be based only on the number prefix right now.

I did try to find an example on the kirby website that would do the same, but I did not fine one where the sub-page was accessible by it own URL.

Is there a way to build a menu like this with the given structure?

Thank you!
Tobias

It looks like this describes the same problem How to ignore subfolder and can be solved by https://getkirby.com/docs/developer-guide/advanced/routing#omitting-the-blog-folder-in-urls.

As the categories are unknown and I would have to search all directories for a unique match, I think it’s better to change the directory structure.

If someone else has an idea, I’d be really happy.

Thanks again
Tobias

Yes, omitting the parent from the URL would lead to issues if two categories have a page with the same UID. Instead of using a nested directory structure, you could put them into just one directory and use a text field for the category. You can then group the pages by category.

Group by is the solution I’ll go with.

Thank you @lukasbestle.