{{ $currentPost := . }} {{ $currentPostIndex := 1 }} {{ $posts := (where $.Site.RegularPages "CurrentSection.Params.Code" "==" $.CurrentSection.Params.Code )}} {{ $postsSorted := (sort $posts "Date" )}} {{ range $index, $element := $postsSorted }} {{ if eq $element.Title $currentPost.Title }} {{ $currentPostIndex = (add $index 1) }} {{ end }} {{ end }} {{ with .CurrentSection.Params.Code }} [{{ . }}{{ print $currentPostIndex }}] {{ end }} {{ .Title }}