Listing all pages without tags


So I want to make sitemap showing content from folders within content folder. But when I list them it’s showing a list of all pages on website including tags. My question is, how can I change this code to list only content from specific folder e.g.: content/adventure/

      {{ range $name, $items := .Site.Pages.ByTitle }}
      <li><a href="{{ .Permalink | relURL }}" title="{{ .Title }}">{{.Title}}</a></li>
      {{ end }}

Do I need to edit 800 posts to add category? Or is there an easier way?


You can use range together with the where function to filter .Site.RegularPages, which returns a collection of all your regular content pages + custom outputs.

For example:

{{ range where .Site.RegularPages "Section" "adventure" }}
    <!-- Do something with all posts from /content/adventure/ -->
{{ end }}


{{ range .Site.RegularPages }}
    <!-- Do something with all posts from /content/,
        excluding tag and category pages -->
{{ end }}

You can find more about range, .Site.RegularPages, and where in the documentation.


Thanks for help and clarification, it now works fine! :slight_smile: