Customizing Hugo’s RSS Feed
Hugo’s default RSS output is enough for many sites. I would customize it only when a feed reader exposes a real problem: the wrong pages appear, summaries are not useful, or the feed title is impossible to recognise beside several subscriptions.
The goal is still a boring XML document that works everywhere. RSS is not improved by making it clever.
Find and advertise the feed first
A Hugo site commonly generates a root feed:
/index.xml
Sections may have their own output too:
/blogs/index.xml
The exact files depend on the output configuration. Link the intended feed in the document head so readers and browser tools can discover it:
<link
rel="alternate"
type="application/rss+xml"
title="Blog RSS feed"
href="/blogs/index.xml"
>
Override only the feed you mean to change
A custom template may live here:
layouts/
└── _default/
└── rss.xml
Hugo’s lookup order varies with the output level being overridden, so check the official Hugo RSS documentation before placing a template and assuming it affects the root or section you intended.
A simplified item loop looks like this:
{{ range first 20 .Pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<guid>{{ .Permalink }}</guid>
<pubDate>
{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}
</pubDate>
<description>
{{ .Summary | html }}
</description>
</item>
{{ end }}
This is only the item portion; keep the surrounding RSS structure from a valid template rather than building it from memory.
Decide between summaries and full articles
For full content, the item can use:
<description>
{{ .Content | html }}
</description>
Full feeds are pleasant to read and keep subscriptions useful offline. Summaries send people to the site and avoid some complications with embedded HTML. Neither choice is universally correct.
Escaping and XML rules matter in both cases. Open the generated file, validate it as XML, and subscribe with at least one real reader. A successful Hugo build does not prove every feed reader will like the markup.
Filter out pages subscribers did not ask for
If the home feed should contain only blog posts, build an explicit collection:
{{ $pages :=
where site.RegularPages
"Section"
"blogs"
}}
Then iterate over it:
{{ range first 20 $pages }}
...
{{ end }}
This prevents project or utility pages from appearing merely because they are regular pages.
A site with distinct, regularly updated content could expose several feeds:
/blogs/index.xml
/photos/index.xml
/projects/index.xml
Two useful choices are better than ten nearly empty ones.
Make the subscription recognisable
The main site title may be just:
Ronalds Vilciņš
In a crowded reader, this is clearer:
Ronalds Vilciņš — Blog
A short description is enough:
<description>
Articles about web development, CSS, Hugo, SEO, and the web.
</description>
Images embedded in full content may already be sufficient, and reader support varies. I would not complicate the feed for one application’s preferred image markup. The same restraint applies to tracking parameters: add them only if the data has a real use.
Treat RSS as a publishing format, not an accidental build artifact. Give it the expected posts, clean links, correct dates, a useful title, and valid XML. That small amount of care is usually all a custom Hugo feed needs.