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