Hugo Template Range Loop Every N Items

I really try to find samples in the discourse before posting. This is a Hugo and bootstrap together question.
I have a collection of Events that I am Ranging over. I want to list items on a page like this:

1 2
3 4
5 6

What I understand of bootstrap is that I need to add a <div class="row"> every two items from my Range. Or…

1 2 3
4 5 6

Would require one every three items.

The number of items does not matter, what I am trying to figure out is how to conditionally add the row break inside the range in a template. Is this supported? Should I be using a Paginator or GroupBy?

You can do this with a regular indexed range using the modBool (or mod) template func. Something ala

OK, I found this:

Now my code is:

{{ $pages := where .Data.Pages "Section" "event" }}
{{ $pages_count := len $pages }}
{{ if ge $pages_count 1 }}
{ range $i, $sorted := $pages.ByParam "start" }}
<div class="event-card__title"><a href="{{ .URL }}" title="{{ .Title }}">{{ .Title }}</a></div>
  {{ if modBool $i 3 }}
    </div> <!-- end row -->
    <div class="row">
  {{ end }}
{{ end }}

But it is adding a row after the first and then every 3 after that.

1
2 3 4
5 6

$i starts at 0 and modBool 0 3 is true. I’m a bit tired after a long day, but I suspect modBool (add $i 1) 3 should work.

Thanks Bep. That fixed it.