Hi everyone,
I’m working on a Hugo site using the Hugo Blog Awesome theme, and I want certain articles to always appear at the top of the list when they have the pinned: true
parameter.
All my articles are organized in subfolders, each containing an index.md
file:
content/
├── article-1/
│ ├── index.md (← This is the article file)
├── article-2/
│ ├── index.md
I added pinned: true
to my articles, like this (comments not in code):
---
title: "Relationship Between Orders: From 1830 to Today"
date: 2025-02-11
author: "Lövbacken"
pinned: true
description: "Chronological Timeline"
---
I modified my list.html
in layouts/_default/list.html
to try and display pinned articles first:
{{ define "main" }}
<div class="wrapper list-page">
<header class="header">
<h1 class="header-title center">{{ .Title }}</h1>
</header>
<main class="page-content" aria-label="Content">
// Pinned articles
{{ $pinnedPosts := where .Site.RegularPages "Params.pinned" true }}
{{ if $pinnedPosts }}
<h2 class="post-year">📌 Pinned Articles</h2>
{{ range $pinnedPosts }}
{{ partial "postCard" . }}
{{ end }}
{{ end }}
// Article by years
{{ range .Site.RegularPages.GroupByDate "2006" }}
{{ $year := .Key }}
<h2 class="post-year">{{ $year }}</h2>
{{ range where .Pages "Params.pinned" "!=" true }}
{{ partial "postCard" . }}
{{ end }}
{{ end }}
</main>
</div>
{{ end }}
- The articles do not appear in the “
Pinned Articles” section, even though
pinned: true
is set in the front matter. - I tried using
.Site.RegularPages
and then.Site.Pages
, but neither worked.
Am i doing anything wrong ?
Thanks in advance for your help