Pages field query, but keep "stepped" UI

When you use the pages field; it shows a nice stepped UI that guides you to find the page you want bu walking over the folder structure.

How do I keep this when using a custom query to exclude certain pages? I tried query: site.index.filterBy('intendedTemplate', 'not in', ['some_template', 'some_other_template']), but that ā€œflattensā€ the structure which is not user friendly for editors when there are lots of pages.

Itā€™s probably due to the .index?
Iā€™ve tried with site.pages.filterBy('intendedTemplate', 'not in', ['some_template', 'some_other_template']) too. That keeps the ā€œstepsā€, but doesnā€™t do the filtering.

Yes, unless you remain on the same level, e.g. in a Starterkit

query: site.pages.filterBy('template', 'in', ['notes', 'photography'])

a query always flattens the list.

The reason why your example doesnā€™t do anything, is because your templates are probably not present on the first level pages (which is what site.pages returns).

Thx Sonja. Including the template of the page ā€˜on the first levelā€™ makes those pages disappear (also in search).

A bit awkward, but it does work.