Order & range by a specified params value

Hello,

I want to create a selected “featured” post section, with an order I can specify manually.

So in the frontmatter of an article I would set the Params “featured”:

+++
featured = “1”
+++

with values of 5 to 1.

Then I want to range the first 5 articles that have a value set for .Params.featured, ordered from 5 to 1.

However, I even fail at the first step, namely just ranging 5 articles that have the Params set. I tried this:

{{ range first 5 (where .Site.Pages.ByDate “Params.featured” “1”) }}

but for some reason it just displays 1 post. Hugo does not give me any error message…

Any ideas what I’m doing wrong?

Thanks in advance!

Look this

According to the linked post, I tried out:

{{ range first 5 (where .Site.Pages “Params.featured” 1) }}

but this does not give me any posts at all…

I think that for debugging, you need to remove “first” and making work correctly “where”. Try this:

where $.Site.Pages "Params.featured" "=" 1

Or do other experiments with this string.

Thank you!

I tried out a bit and found out that
{{ range first 5 (where $.Site.Pages "Params.featured" "=" "1") }}
does work as desired.

Now I’ll have to to figure out how I can set different values for the Params.featured (1-5) and order the results.