# Can I get the current iteration from \`{{ range .Pages }}\`?

**URL:** <https://discourse.gohugo.io/t/can-i-get-the-current-iteration-from-range-pages/30435>\
**Category:** support\
**Created:** [January 5, 2021, 10:33pm UTC](https://discourse.gohugo.io/t/can-i-get-the-current-iteration-from-range-pages/30435 "2021-01-05T22:33:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![i732](https://avatars.discourse-cdn.com/v4/letter/i/5e9695/32.png) [@i732](https://discourse.gohugo.io/u/i732)\
**Post date:** [January 5, 2021, 10:33pm UTC](https://discourse.gohugo.io/t/can-i-get-the-current-iteration-from-range-pages/30435/1 "2021-01-05T22:33:35Z")

</div>

I need to set a id to an incremented value, is there any way I can get the current count that I’m on OR increment my own value each loop?

Currently my way of doing it is:  
{{ $count := 0 }}  
{{ range .Pages }}  
{{ $count = add $count 1 }}  
{{end}}

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [January 6, 2021, 4:55am UTC](https://discourse.gohugo.io/t/can-i-get-the-current-iteration-from-range-pages/30435/2 "2021-01-06T04:55:40Z")

</div>

```auto
{{ range $iteration, $value := .Pages }}
{{ $value }}
{{ $iteration }}
{{ end }}

```

$value is what the dot `.` was before, $iteration should increase starting from zero. But your way is right too.

On a related note: `ID` as such, if you want to have a real unique identification method for example an article - try this:

```auto
<article{{ with .File }} id="x{{ .UniqueID }}"{{ end }}>

```
