hi, it's mike ʕ•ᴥ•ʔノ

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

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:

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.

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

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

1<description>{{ .Summary | html }} <br />
2   {{ partial "rss_tags.html" . }}
3</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:

 1outputs:
 2  home:
 3    - HTML
 4    - RSS
 5    - SocialRSS
 6    - JSON
 7
 8outputFormats:
 9  RSS:
10    mediatype: "application/rss+xml"
11    baseName: "index"
12    isPlainText: true
13    notAlternative: true
14
15  SocialRSS:
16    mediatype: "application/rss+xml"
17    baseName: "social"
18    isPlainText: true
19
20mediaTypes:
21  "application/rss":
22    suffixes: ["xml"]

#Hugo #Rss #Design