How to sort by date descending, but force pinned messages (also descending) first?

Hey! I am making a standard blog, but I want to have 0, 1 or more pinned posts in the beginning of the list (sorted newest to oldest).

Basically I would have
PINNED NEWEST

PINNED OLDEST
NON-PINNED NEWEST

NON-PINNED OLDEST

I am playing around with the code bellow but it throws “Rebuild failed:Failed to render pages: render of “section” …can’t evaluate field RelPermalink in type page.PageGroup”

{{ range (.Pages.GroupByParam “pinned”).Reverse }}
{{ range .Pages.ByPublishDate.Reverse }}
{{ range .Pages.GroupByParam “pinned” }}

My FM has the structure if pinned:
+++
title = “PINNED POST Post”
date = “2010-08-13”
tags = [“three”, “article”]
pinned = true
+++

If NOT pinned, then it is either pinned = false, or pinned is missing completely.
I do have this in config.toml as a fallback but am unsure if it does anything; the intention is fallback in case I don’t mention that parameter in each individual post MD.

[params]
pinned = false

How can one use range where and use $.Param? I have a pinned = false in the config, and some MD posts have pinned = true and some pinned = false and I want to filter by this property in a where :confused:

Hard to understand what you’re trying to achieve here. If your config pinned param is set to false , then using .Param "pinned" will only return the site config (false) when the parameter is not set on that page.

So… I think what you want is to only display the posts with .Params.pinned set to false, or not set.

In this case

{{ range where "Params.pinned" nil }} 
[ ... ]
{{ end }}

Should work…

Thank you for your reply!
I made a more elaborate post on what my issue is:

No double posting please. A support ticket for a specific issue needs to be in one place.

I have merged that topic with this one.

1 Like

Can you post your code here? Thanks.

can’t, they said I shouldn’t be doubleposting

You can paste it here. The code including the .RelPermalink which throws the error. Thanks.

There was a second topic about the same issue that was reworded.

That has nothing to do with the request to post the code in question.

We do have guidelines in this forum about Requesting Help and we usually ask to see a repository with the entire Hugo project. So it would be best if you did that.

Also the error that you report in your original post:

can’t evaluate field RelPermalink in type page.PageGroup”

Seems like a problem with the pagination code and it also seems unrelated to the pinned parameter that you mention.

So to clear things up (unless you’ve solved the issue on your own) then at the very least do as @regis asked and share the code.

Thanks.

Due to a request this topic is now unlisted from the forum but it cannot be deleted.

In the future @Alexandru_Nechita please read the Requesting Help topic it will save time.