Get one item of a .Page "array"

I am trying to find the right function to get the first of many page objects/arrays/items.

For instance I am grouping posts by date:

{{ range (where .Site.Pages "Section" "post").GroupByDate "January 2006"}}

How would I “grab” the first of the pages in this array so I can work through it with .Date and .Title aso.?

I would guess it’s something like .Pages.0.Date but that does not work. Also thought that “slice” would be a function that helps here, but the way I read the documentation this is more a string thing?

I tried to work with an index in the range command, but somehow only produce errors due to the .GroupByDate part.

Any help is appreciated :slight_smile:

Check out the first function in documentation.

1 Like

Great. That did it :slight_smile:

first returns a slice, which you may or not want.

index .Pages 0 will get you the first (you may want the length first using len to void errors).

2 Likes

I’ll try that. thank you.