Looping through static pages at the root of content

I have pages at the root of content directory with the type = "post" so I wanted to loop through to display them and I did this:

{{ range where .Site.Pages "Type" "page" }}
  {{ .LinkTitle }}
{{ end }}

which lists my pages but it also lists all my tags making it more than I expect. How can I make it just those content pages where I explicitly set a type taxonomy on

Try replacing page with post.

1 Like

That was worse. Showed all my actual blog post. But seeing that made me think of something else. The few pages I’m targeting have layout = "page" so I changed Type to Layout and it gave me what I wanted.

Glad it worked, but you should look through the docs for the meanings of type, layout, etc. Also note the difference between .Pages and .RegularPages.

1 Like

It’s actually kinda inconsistent. The pages get displayed on actual blog posts but when I click a page that loop is empty on the page itself

Use

{{ range where .Site.RegularPages "Type" "page" }}
1 Like

That worked. Thanks