I’m looking for a way to display posts ordered in such a way that if I set lastmod in frontmatter manually it will act as a date, so the post will appear higher in a loop. I don’t need to set lastmod automatically via config, just manual updates, so users can see freshly updated articles higher in the loop.
To visualize this, the order should be something like that:
Ok, that works now, but now Hugo is setting lastmod automatically for all the posts. This is something I don’t need because the business wants to pick which post to update and promote, and with this setup even changing one letter will put the post on top of the loop.
I’m thinking about some kind of arrays of merge/sort to achieve this, if it’s not possible with standard functions, but I guess I will still could use a little help with this.
git clone --single-branch -b hugo-forum-topic-42495 https://github.com/jmooring/hugo-testing hugo-forum-topic-42495
cd hugo-forum-topic-42495
hugo server
Perhaps you have enableGitInfo = true in your site configuration, in which case the last modified date is extracted from the Git commit info. See docs.
If the purpose of this is to promote (or “pin to top”) one or more pages, have you considered simply adding promote = true to front matter?
Now that’s awkward. Your project works just fine. But mine is not, despite the fact that I’ve deleted everything related from the config file and I am using your code:
{{ $p := site.RegularPages.ByLastmod.Reverse }}
{{ range (.Paginate $p).Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}