3 <ol class=
"crumbs" itemscope
itemtype=
"https://schema.org/BreadcrumbList">
4 {{- /* declare a 'variable' to store the each link position */}}
5 {{- $data := newScratch }}
7 {{- range $index, $value := .Ancestors.Reverse }}
8 <li class=
"crumb-item" itemprop=
"itemListElement" itemscope
itemtype=
"https://schema.org/ListItem">
9 {{- /* read the index from loop and add 'one', because it starts counting from zero */}}
10 {{- $data.Set
"counter" $index }}
11 {{- $data.Add
"counter" 1 }}
12 <a itemprop=
"item" href=
"{{.Permalink}}">
14 <span itemprop=
"name">home
</span>
16 <span itemprop=
"name">{{.Title}}
</span>
19 {{- /* pass the counter value into schema attribute */}}
20 <meta itemprop=
"position" content='{{ $data.Get
"counter"}}'
/>
23 <li class=
"crumb-item active" itemprop=
"itemListElement" itemscope
itemtype=
"https://schema.org/ListItem">
24 {{- /* add 'one' one more time for the last link position */}}
25 {{- $data.Add
"counter" 1 }}
26 <span itemprop=
"name">{{.Title}}
</span>
27 {{- /* pass the counter value into schema attribute */}}
28 <meta itemprop=
"position" content='{{ $data.Get
"counter"}}'
/>