Log in Sign up

Query Pages / Custom Menu

Is there a way to query all Pages (instead of Posts) in order to create a custom menu?

It looks like {{#all_entries}} doesn't included anything flagged as a page in the meta data, resulting in the inability to filter out only the pages using something like {{#Page}} within the {{#all_entries}} query.

Use case: I'd like to create a secondary (footer) menu where I can list a different set of pages than what is shown in the main menu. In the meta data something like this could be used:

Page: yes
Footer: yes

Ideally I could query for {{#Page}} and then within that {{#metadata.footer}} (or something of the sort) to pull the desired pages.

In terms of creating a menu, I could likely wrangle the {{#menu}} query and do something fun within it but I didn't know if there was an easier way to list Pages and not Posts


3 years ago, 2 replies   Edit question

There isn't a way to list pages right now, but I'm open to adding it. For now, you'll need to wrangle {{menu}}, you'll want to do something like this:

{{#menu}}
  {{#metadata.footer}}
  <a href="{{{url}}}">{{label}}</a>
  {{/metadata.footer}}
{{/menu}}

Does that get you sorted for now?

Answered 3 years ago · Edit answer

Yes, that makes sense. I wanted to make sure I wasn't missing something more obvious first.

Answered 3 years ago · Edit answer