$.Site.Pages subsection without list view

Hi!

I am iterating over a section in a navigation partial, like so:

{{ range where $.Site.Pages.ByTitle "Section" "guidelines" }} <li><a href="{{ .Permalink }}">{{ .Title }}</a></li> {{ end }}

I have two problems:

  1. I want to show just the subsection “interaction” (which is in my content under guidelines/interaction)
  2. I want to exclude the list view which automatically gets added (i.e. where .Title is “guidelines” and it lists all content)

I’m very new to this templating language. Thanks very much for your help!

For (1), perhaps add an if statement within the range?

{{ if eq .Params.categories "interaction" }}
   ... Do things ...
{{ end }}

Though I’m not sure on how to access the subdirectory off-hand.

For (2), you can either:

  • Make /layouts/_default/list.html blank (or whatever else you want it to be)
    Which will affect all list pages.
  • Make /layouts/guidelines/list.html blank (or whatever else you want it to be)
    You might need to create this to do so, but it will only affect everything in the guidelines section (that is, /guidelines/...)
1 Like

Nested sections are not currently supported but are on the roadmap for the next release. Therefore content/guidelines/interaction/ and content/guidelines/ are both in the “guidelines” section.

That said, you could always filter based on a param that is unique to each of the content files under guidelines…

Okay, looks like I’ll have to be explicit for categories, then. Thanks for the tip!

Just tried your suggestions for 2. A blank list.html unfortunately does not remove the list item, which then links to a blank page.

?

Edit I also tried using {{ .Render “li” }}, using an li.html template under guidelines, but that didn’t help either.

I obviously have very little knowledge about your site, but have you considered treating “categories” like a Taxonomy instead?

1 Like

No, but I’ll look into it! I’m not currently very familiar with taxonomies.