Hugo Tips: Generate Full-Text RSS/Atom Feeds

  ·   1 min read

Unless a blog writer want to drive traffic increase for their site, a full-text RSS/Atom output is usually more friendly to readers than summary. It allows feed aggregator (like Feed Wangler or FeedBin grab output without additional processing. Though it increases the size of RSS/Atom file, it’s generally not a big problem in current Internet bandwith.

My site is built on Hugo. By default, Hugo generates output with summary only. But we can enable full-text output with a simple hack.

I did it by creating a layouts/index.rss.xml to overwrite the default feed template. I didn’t modify too much: just one line indeed:

... <!-- until line 28 -->
    {{ range $pages }}
    <item>
      <title>{{ .Title }}</title>
      <link>{{ .Permalink }}</link>
      <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
      {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
      <guid>{{ .Permalink }}</guid>
      <!-- It was
          <description>{{ .Summary | html }}</description>
      Now change to: -->
      <description>{{ .Content | html }}</description>
    </item>
    {{ end }}
  </channel>
</rss>

Now, rebuild the site code and enjoy new feeds starting since this post.

Credit

Thanks to discussion at https://discourse.gohugo.io/t/full-text-rss-feed/8368/2 to inspire me the solution. Also, thanks the great Hugo documentation