Nested pages parent/child/child

I have build a website with another flatfile cms.
But now i will try rebuilding this website with GRAV.

I have needed this structure:
-province 1/city 1/location 1
-province 1/city 1/location 2
-province 1/city 2/location 1
-province 2/city 1/location 1
province x/city x/location x

So this is the structure of the website now, what is the most efficient way building this structure in GRAV?

  • parent/child/child?

If it’s possible, is there a filter searching all this parent/child Pages?

@ctuxboy, As always, it depends…

Based, for example, on one or more of the following criteria:

  • Navigation style of the site
  • Functionality provided to the user
  • Maintainability of pages in terminal or Admin.

Restricting myself to your site only…

One of the core features of Grav are collections of pages. Collections can be based on the hierarchy of folders (e.g. page.children, page.descendants, page.siblings), or based on Taxonomy, or a combination of both.

Looking at your site, currently, a user navigates through your site by selecting a child of the current page from a list (read collection) of children. Structuring your folders in a hierarchy will automatically create the correct collections for each page. This will make creating the list of children very easy.

However, I can imagine your users would also like to search for dog parks based on some criteria: parking, fenced or agility facilities. Based on the taxonomy (categories, tags, …) added to the header of pages, a collection can be created and filtered based on the search criteria of the user.
Taxonomy collections are independent of the folder structure being used.

Both types of collections can be mixed together, like “all descendants of page X that have been labelled with ‘fenced’”.

Also, collections can be created programmatically in both Twig and PHP.

1 Like

Thanks a lot for your useful answer :pray:
This is the answer i’m waiting for!
Okay, i think collections is what i needed for building this :smiley:
The reason asking this, starting a good fundament for all the content (provinces/cities/dogzones).
The functionality in are, at the moment, very basic.
‘behind the scenes’ it’s also a flatfile CMS that works with filters:

  • when click on a province, all the cities (child-pages) where filtered by it’s template city
  • showing the city => showing all the child-pages (dogzones) in the city
  • ‘technically’ it is also possible show all the dogzones by it’s template ‘dogzone’

Here you can see, how the hierarchy is build…

Is it also possible filtering by ‘template’?
I mean, is it possible showing ONLY all the cities/dogzones independent from the provinces/cities in GRAV?

In the near future i will rebuild with more filters/search-options and a new layout:

  • search by geolocation
  • adding a searchbox
  • (login) user comments
  • star-reviews
  • adding more (detailed) content/services

I think that GRAV, gives me more flexibility building this project.


Is it also possible filtering by ‘template’?

You cannot create a collection based on templates, but your can filter on templates.

Having said that, I think it is more efficient to create a collection based on taxonomy, instead of creating a collection of all pages and filter on ‘template’. Taxonomy basically uses a pre-build and cached associative array of categories with an array of pages.

Anyway, I would suggest to read the docs… You’ll find your answer in section Complex Collections.

I know asking is quicker and easier, but reading the docs will yield so much more knowledge… :wink:

Hi @pamtbaau thanks for your advice.
filter by template = AWESOME :smiley:

If i understand what you mean, adding also this 3 taxonomies to the certain (child)pages, for filtering:

  • province
  • city
  • dogzone

Okay, i read about the Complex Collections and do my research, about the best way, how manage all the content.


Since a page can only be one of ‘provincie’, ‘city’, ‘dogpark’, you only need a single taxonomy variable for it.


  level: dogpark # or provincie, or city, or dogpark

To get all dogparks, you can then create a collection like @taxonomy.level: dogpark

Hi @pamtbaau ,
Thanks a lot man.
You help me out how manage all the data :smiley:
Follow 100% your advice!!!
Yesterday, started make a full customized Bootstrap-theme, i know there are existing (bootstrap) themes, but i loved building it myself, so i learn a lot how all the ‘things’ work.
Sometimes using the CLI console, works awesome :crazy_face:
This night, start make also my first blueprint. It gives a lot of possibilities.
I want making 3 blueprints with a default taxonomy ‘level’ (thanks for this tip!) each:

I’m super motivated rebuilding with GRAV :partying_face:

PS: i’m not a pro-programmer, but i like do some (basic) developing work and sorry for my poor english :relieved:

I’m really happy with your support, you let me think the right way :slightly_smiling_face:

@ctuxboy, What are the access paths you are going to provide the user?

  • If the user only traverses down provincie → antwerpen → ravels → dogparks, you would loop page.children() inside Twig for all pages except the dogpark pages.
    In this case there is no need for taxonomy.level.

  • Only if you want to show the user a list of all registered cities (from all provinces combined), you would use the taxonomy.level: city. And, frankly, I don’t see this being useful for the user… I wonder if taxonomy.level is needed at all.

  • I do see a use-case for a list of all dogparks based on a selection of properties, like ‘parking’, ‘fenced’. Taxonomy would be a good fit for this.

As a side note, I don’t see much difference between province and city. They both show a list of children. They might be able to share the same blueprint/template.

Taxonomy is good solution but maybe better way is to have custom content type for province/city/dogpark as all of them can have than diffrent content (form) and different look;). Page collection with content type filter and children/descendants…?


Yes, traverses down, province/city/dogparks also is better for building breadcrumbs(?), and some logic, so when the user look to a specific dogpark, and will see all the dogparks from a city, he/she can click in the breadcrumb city and shows all the dogparks for this city.
But it, i think in specific use cases, adding also taxonomy.level, so it gives more flexibility.

  • Yes, filter by specific dogpark properties, is also an idea that i will develop in the future.

The blueprints for provinces and cities, are similar, you have a good point!

@tunkila that was the reason, why i choose 3 different blueprints, but it is also possible choose the same blueprint for city and province and using ‘conditions’ in the twig-templates {% if city %}... {% else %}...
So i think if i have some idea’s for different content for both.