Simple Iteration

I am trying to do this:

{% for i in (0..24) %}
  <li>
    <img src="https://profilepageimages.usecue.com/images/{{ include.username }}/small/{{ i }}.jpg" alt="Instagram picture {{ i | plus:1 }}" />
  </li>
{% endfor %}

Its so simple but totally unfathomable for me from hugo documentation.

Apologies
David

Hi David,

I edited your post, enclosing your code within code fences so that it is easier for others to understand your question.

I think you want something like this:

{{ range $i := seq 0 24 }}
<li>
  <img src="https://profilepageimages.usecue.com/images/{{ $username }}/small/{{ $i }}.jpg" alt="Instagram picture {{ add 1 $i }}">
</li>
{{ end }}

References:

1 Like

Thanks a million for your help.

David

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