Using front matter parameter in range to order tabs also includes section name tab

Hello,

I have just begun playing with Hugo functions and templates. In my site, I have this structure:

content
|_ main
     |_about.md
     |_ resume.md
     |_ contact.md

And I have title and pageseq as front matter parameters.

I am trying to render them in index.html as tabs, and I am ordering these tabs using pageseq parameter.

My code:

{{ range (where .Site.Pages "Section" "main").ByParam "pageseq" }}
    <li class="tab"><a href="#{{ lower .Title }}" class="teal-text text-darken-4"><i class=""></i>{{ .Title }}</a></li>
{{end}}

However, I get four tabs instead of three. Mains is rendered as one of the tabs. I don’t know where that is coming from, and how to avoid that. Can someone help me?

@sejal27 I assume you have params pageseq: true in your front matter, You can try this

{{ range .Site.Pages }}
      {{ if in .Params.pageseq "true" }}
        ---Your Code Here----
      {{ end }}
{{ end }}

Note: You have to use double quote on you params "true"

{{ if .Params.pageseq }} also should work.

1 Like

Ah great that would be simpler than mine :blush:

If I understood the question correctly, then you should use Nest where Clauses.

{{ range (where (where .Site.Pages "Section" "main") ".Params.pageseq" true).ByParam "pageseq" }}
1 Like

Yes, thats simpler. :slight_smile: