Full content in the RSS feed (and how to add a second Hugo feed)

· 374 words · 2 minute read

It took me a while to figure it out after a failed first attempt, but I finally made a full-content RSS feed. It’s going under the same name as it was before as a partial feed, so it ought to just start providing the full content of posts now.

Previously I was using a modified feed that was meant to work well for social syndication (e.g. cross-posting to Mastodon and Twitter). It included just the post summary plus + tags as a way to aid with discovery (especially in Mastodon). That didn’t sit super well with me – I’m a “full content” kind of person – but figuring out how to get Hugo to do two feeds took some doing.

While I was in there, I also shortened the length of the feeds to 20 posts. I think there are a few more things to do to make it all work just so, but I’m content to just have a full content feed back in place for now. Also, if you liked the old feed format (I guess some people like summaries and clicking through?) it’s still around, but I renamed it to /social.xml, since its primary purpose is driving an IFTTT cross-posting recipe.

Setting it up 🔗

If you’re curious about how the two feeds are configured:

First, you need two template files in your site’s layouts/_default directory:

  • rss.xml
  • list.socialrss.xml

The first one is a standard Hugo RSS template with a slight modification to the description property to use the full content of a post vs. the summary.

<description>{{ .Content | html }}</description>

The second template uses the post summary, and adds a partial:

<description>{{ .Summary | html }} <br />
   {{ partial "rss_tags.html" . }}
</description>

The partial is how I get post tags for use in syndication to the social feed. Mastodon clients tend to auto-link hashtags, and hashtags are key to discovery in Mastodon:

{{- $tags := .Language.Params.Taxonomies.tag | default "tags" }}
{{- range ($.GetTerms $tags) }} #{{ .LinkTitle }}  {{- end }}

config.yml looks like this in my setup:

outputs:
  home:
    - HTML
    - RSS
    - SocialRSS
    - JSON

outputFormats:
  RSS:
    mediatype: "application/rss+xml"
    baseName: "index"
    isPlainText: true
    notAlternative: true

  SocialRSS:
    mediatype: "application/rss+xml"
    baseName: "social"
    isPlainText: true

mediaTypes:
  "application/rss":
    suffixes: ["xml"]