summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Johnson <>2026-09-18 00:00:00 +0000
committerNicholas Johnson <>2026-09-18 00:00:00 +0000
commitf7010449afad2fea6da148330d201529ccc2d65ce50e31083d605c5733c4afa2 (patch)
tree2f4f379e5354ceb09b52d9ff75c29bce0a6c7f949d2f8266b850fd4557a0c9f2
parent4261deef2716d60664fb17829f786f50dbddcf0649aa96a7ba65fe30d04e9c36 (diff)
downloadhugo-theme-journal-f7010449afad2fea6da148330d201529ccc2d65ce50e31083d605c5733c4afa2.tar.gz
hugo-theme-journal-f7010449afad2fea6da148330d201529ccc2d65ce50e31083d605c5733c4afa2.zip
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 <noreply@anthropic.com>
-rw-r--r--layouts/home.atom.xml7
-rw-r--r--layouts/home.gemini_atom.xml7
-rw-r--r--layouts/taxonomy.atom.xml7
-rw-r--r--layouts/taxonomy.gemini_atom.xml7
-rw-r--r--layouts/term.atom.xml7
-rw-r--r--layouts/term.gemini_atom.xml7
6 files changed, 36 insertions, 6 deletions
diff --git a/layouts/home.atom.xml b/layouts/home.atom.xml
index c4f4eae..47b4233 100644
--- a/layouts/home.atom.xml
+++ b/layouts/home.atom.xml
@@ -18,6 +18,11 @@
{{- end }}
{{- end -}}
+{{- $pages := .Site.RegularPages }}
+{{- $limit := .Site.Config.Services.RSS.Limit }}
+{{- if ge $limit 1 }}
+{{- $pages = first $limit $pages }}
+{{- end -}}
{{ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom">
<id>{{ .Permalink }}</id>
@@ -33,7 +38,7 @@
</author>{{ end }}
<generator>Hugo -- gohugo.io</generator>
<rights type="html">{{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }}</rights>
- <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range first .Site.Config.Services.RSS.Limit .Site.RegularPages }}
+ <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range $pages }}
<entry>
<id>{{ .Permalink }}</id>
<title type="html">{{ .Title }}</title>
diff --git a/layouts/home.gemini_atom.xml b/layouts/home.gemini_atom.xml
index 6189f83..ac8f412 100644
--- a/layouts/home.gemini_atom.xml
+++ b/layouts/home.gemini_atom.xml
@@ -18,6 +18,11 @@
{{- end }}
{{- end -}}
+{{- $pages := .Site.RegularPages }}
+{{- $limit := .Site.Config.Services.RSS.Limit }}
+{{- if ge $limit 1 }}
+{{- $pages = first $limit $pages }}
+{{- end -}}
{{ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom">
<id>{{ .Permalink | strings.TrimSuffix "index.gmi" }}</id>
@@ -33,7 +38,7 @@
</author>{{ end }}
<generator>Hugo -- gohugo.io</generator>
<rights type="html">{{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }}</rights>
- <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range first .Site.Config.Services.RSS.Limit .Site.RegularPages }}
+ <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range $pages }}
<entry>
<id>{{ .Permalink | strings.TrimSuffix "index.gmi" }}</id>
<title>{{ .Title }}</title>
diff --git a/layouts/taxonomy.atom.xml b/layouts/taxonomy.atom.xml
index 1364f27..3b5a1ca 100644
--- a/layouts/taxonomy.atom.xml
+++ b/layouts/taxonomy.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 -}}
{{ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom">
<id>{{ .Permalink }}</id>
@@ -33,7 +38,7 @@
</author>{{ end }}
<generator>Hugo -- gohugo.io</generator>
<rights type="html">{{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }}</rights>
- <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }}
+ <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range $pages }}
<entry>
<id>{{ .Permalink }}</id>
<title type="html">{{ .Title }}</title>
diff --git a/layouts/taxonomy.gemini_atom.xml b/layouts/taxonomy.gemini_atom.xml
index d8ab06e..5341d32 100644
--- a/layouts/taxonomy.gemini_atom.xml
+++ b/layouts/taxonomy.gemini_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 -}}
{{ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom">
<id>{{ .Permalink | strings.TrimSuffix "index.gmi" }}</id>
@@ -33,7 +38,7 @@
</author>{{ end }}
<generator>Hugo -- gohugo.io</generator>
<rights type="html">{{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }}</rights>
- <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }}
+ <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range $pages }}
<entry>
<id>{{ .Permalink | strings.TrimSuffix "index.gmi" }}</id>
<title>{{ .Title }}</title>
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 -}}
{{ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom">
<id>{{ .Permalink }}</id>
@@ -33,7 +38,7 @@
</author>{{ end }}
<generator>Hugo -- gohugo.io</generator>
<rights type="html">{{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }}</rights>
- <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }}
+ <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range $pages }}
<entry>
<id>{{ .Permalink }}</id>
<title type="html">{{ .Title }}</title>
diff --git a/layouts/term.gemini_atom.xml b/layouts/term.gemini_atom.xml
index d8ab06e..5341d32 100644
--- a/layouts/term.gemini_atom.xml
+++ b/layouts/term.gemini_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 -}}
{{ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom">
<id>{{ .Permalink | strings.TrimSuffix "index.gmi" }}</id>
@@ -33,7 +38,7 @@
</author>{{ end }}
<generator>Hugo -- gohugo.io</generator>
<rights type="html">{{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }}</rights>
- <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range first .Site.Config.Services.RSS.Limit .Data.Pages }}
+ <subtitle>{{ .Site.Params.Description }}</subtitle>{{ range $pages }}
<entry>
<id>{{ .Permalink | strings.TrimSuffix "index.gmi" }}</id>
<title>{{ .Title }}</title>