How to call even or odd numbered pages using range funtion in hugo

I am fine with {{ range first 10 .Data.Pages }} but when I want to call some specific numbered posts or specific range, its hard to me to write the code. How to call custom pages using range function?

If you want to loop through a set of specific pages, here is the code with explanation.
You could try modifying this if you have a custom archetype or variable with similar parameters like the Post DateTime or if you have numbered the posts.

Try if you can use .NextInSection recursively.

Add a new param inside your content/post/ inside the +++

see_also = ["file-name-4", "file-6"]

Now in your single.html add the following -

  {{ if isset .Params "see_also" }}
  {{ $seeAlso := index .Params "see_also" }}
  <h4>See Also</h4>
    {{ range where .Site.Pages "Section" .Section }}
    {{ if in $seeAlso .File.BaseFileName }}
      <li><a href="{{ .RelPermalink }}" alt="{{ .Title }}">{{ .LinkTitle }}</a></li>
    {{ end }}
    {{ end }}
  {{ end }}
  1. First checks if the param see_also is set in the markdown/html file (in the content directory)
  2. We iterate through all Pages in the current Section (otherwise, it will use all the pages in the current project)
  3. Matches the list based on the filename
  4. Display the link
1 Like