Hugo

How can I sort Section's items

Hello. I have the code in my templates

{{ range ( sort (where .Site.RegularPages "Section" "events") ".Params.id" "desc") }}
{{ end }}

I have pages with parameters

+++
layout 			= "events_form"

## Meta
title			= "Test"
description		= "test"

## Date
date			= "2019-09-01T00:00:00+03:00"

id				= 2
+++

But sorting doesn’t work. I always see order by name.

read this

Untested, but try something like this:

{{ $pages := where site.RegularPages "Section" "events" }}
{{ range ($pages.ByParam "id").Reverse }}
...

Reference