Custom Collection for Footer?

I’m struggling with trying to figure out how to create a custom navigation list for my footer. I want to have a folder with pages, and have my footer navigation be populated with links to those pages.

This is what I feel like should work:


        '@page.children': '/footnav'
        by: default
        dir: desc


{% for p in config.themes.steadystation.footnav %}
{{ p.title }}

Pages Folder Structure


The above doesn’t work.

I’ve tried lots of other things and cannot seem to get it to work. Is this even the right approach? Should I be defining a collection in the theme yaml? Do I even need a collection? My main nav is just using pages.children.visible in the TWIG. I don’t know how to edit that to only look in one folder. I’ve tried pages.footnav.children.visible, but that doesn’t seem to work.

I figured out how to do it with Taxonomies. I have not yet used taxonomies for anything yet, and this was an easy solution.

I edited to have

taxonomies: [place]

Added the appropriate Taxonomy to each page:

     place: footer

Then used this in my TWIG:

{% for page in taxonomy.findTaxonomy({'place':'footer'}) %}

You can mark your own answer as a solution :wink:

I also use category taxonomy for that exact purpose. And I’m not sure themes can have page collections :thinking: I always thought they can be created only in page header

1 Like

@Karmalakas, See Programmatic collections:

You can take full control of collections directly from PHP in Grav plugins, themes, or even from Twig. This is a more hard-coded approach compared to defining them in your page frontmatter, but it also allows for more complex and flexible collections logic.

Probably that’s why I didn’t fixate that to my memory :slight_smile: I didn’t really use the usual way of getting collections on my site - everything is in my custom theme templates as page.children and similar