Iterating through content on list pages

So, on my index page I have several partials with code like this:

{{ range (where .Data.Pages “Section” “arbitraryfoldername”).ByParam “rank” }}
{{ .Content }}
{{ end }}

It goes through the content from folder “arbitraryfoldername” like I want it to. However, for the sake of nicely organized content, I would like to use this on some of my list pages just by changing the “arbitraryfoldername”. It doesn’t work at all. I could use {{ range .Data.Pages }} but it only goes through the content of one specific folder. Am I organizing my content incorrectly or is the command incorrect?

Also, is there an easy way to tell the loop to take some action every n iterations? This would be useful for creating alternating white/gray backgrounds for lists or creating a div around every two bootstrap col-sm-6’es.