Listing all pages without tags

Hi,

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/

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

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

Cheers!

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 }}

…or…

{{ 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.

2 Likes

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