From f7010449afad2fea6da148330d201529ccc2d65ce50e31083d605c5733c4afa2 Mon Sep 17 00:00:00 2001 From: Nicholas Johnson <> Date: Fri, 18 Sep 2026 00:00:00 +0000 Subject: Fix build failure when RSS limit is unset Hugo's default for services.rss.limit is -1 (unlimited), and passing a negative length to "first" aborts the build with "sequence length must be non-negative". Every feed template did this unconditionally, so any site that did not explicitly set services.rss.limit failed to build at all, rather than degrading to an unlimited feed. Only apply "first" when a positive limit is configured, which is the same guard Hugo's own internal RSS template uses. Co-Authored-By: Claude Opus 5 --- layouts/term.atom.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'layouts/term.atom.xml') diff --git a/layouts/term.atom.xml b/layouts/term.atom.xml index 1364f27..3b5a1ca 100644 --- a/layouts/term.atom.xml +++ b/layouts/term.atom.xml @@ -18,6 +18,11 @@ {{- end }} {{- end -}} +{{- $pages := .Data.Pages }} +{{- $limit := .Site.Config.Services.RSS.Limit }} +{{- if ge $limit 1 }} +{{- $pages = first $limit $pages }} +{{- end -}} {{ "" | safeHTML }} {{ .Permalink }} @@ -33,7 +38,7 @@ {{ end }} Hugo -- gohugo.io {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} - {{ .Site.Params.Description }}{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }} + {{ .Site.Params.Description }}{{ range $pages }} {{ .Permalink }} {{ .Title }} -- cgit v1.2.3