How to Add RSS Feed to your Hugo Blog

  • YC YC
  • |
  • 29 September 2022

RSS, which stands for Really Simple Syndication, is a very powerful tool to publish and keep your readers updated with new content to your website. Comes in the form of a XML file, it consist of the latest update of your website. Every update usually represents a page and it consist of the title, summary and a link back to the actual article. A RSS feed reader will fetch this XML file and display the updates in a human readable dashboard.

As an owner of a blog, getting your new articles out to your audience is key. Thankfully Hugo supports auto generation of RSS file out of the box. However default Hugo RSS file generates content based on all pages in website, include pages like “About Me”, “Contact Me” etc. Having updates of these pages update in your reader’s dashboard is certainly not impressive and unnecessary. Hence in this article I am going to show you how to include only blog post in Hugo’s generation of RSS file and how to hint RSS reader to discover your RSS file.

First we need to add the default Hugo RSS template to your theme. Download the template from This template is mature and does not get frequent updates, so you should only need to do this once barring some major updates.

After downloading this file, place it inside the default layout folder of your theme themes/<theme name>/layouts/_default/. Rename the file to index.rss.xml.

Next open up the file andd look for

    {{ range $pages }}

Replace it with

    {{ range where (where .Site.Pages ".Section" "blog") "Kind" "page" }}

Now your RSS will display only your blog post.

Next we going to add a hint to allow browsers or RSS reader to find the location of your RSS file.

Add the following html code into the <head> section of your homepage

<!-- rss -->
{{ with .OutputFormats.Get "rss" -}}
    {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}

Now you can just enter the url of your blog and most RSS reader would be able to find your RSS file and list all updates of your blog.

comments powered by Disqus

You May Also Like