---
title: Dictionary Indexing
xdescription:
- AA
- BB
- CC
- DD
---
I am tring to show all of them except the first one as list. I wrote the following code to do but it is not displaying items. Any idea how to display all elements except the first one?
Below is the code I tried:
{{ with .Params.xdescription}}
<h2>Description___</h2>
{{ range $i, $myElement := . }}
{{ if gt $i 1 }}
{{ $i }}
{{ $myElement}}
{{ end }}
{{ end }}
{{ end }}
The correct value to access this configuration is .Site.Params.xdescription. .Params is to access the front matter of the current page.
Also, the first element of a slice is 0, not 1 so you may want to change that if check to if gt $i 0.
A better way to achieve this would be to create a slice where the first element is removed and you just loop over it. This can be implemented as follows:
{{ with .Site.Params.xdescription}}
<h2>Description___</h2>
{{ $list := last (sub (len .) 1) . }}
{{ range $list }}
{{ . }}
{{ end }}
{{ end }}