HUGO

How do you repeat a range of images?

I have 20 product images which I would like to loop through multiple times as I’m trying to created a scrolling image banner, like a carousel.

The following code shows the images once:

<div>
  <div>
    {{range .Params.images}}
      {{$img := (site.GetPage "/products/assets").Resources}}
      {{$img := $img.GetMatch (printf "%s.*" (anchorize .))}}
      {{with $img}}
        <img src="{{.RelPermalink}}">
      {{end}}
    {{end}}
  </div>
</div>

How would I go about repeating this? I believe seq might be the right function to use, but struggling to get it to work.

Wrap your existing range within another range.

{{ range seq 3 }} 
 ...
{{ end }} 
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.