Finally figured out how to disable RSS feeds on a post by post basis.
I needed to do this for my stream of consciousness / wip / progress notes in the Notes and Miscellanea section I did not want to disable the whole section, because some posts, I do want to leak out.
What it boiled down to was getting the RSS template to ignore sites with some parameter set in the front matter. Most posts on the web do a rss_disabled: true
or something to that effect.
Joe Mooring over on the Hugo Discourse logically pointed out that I’d want such posts to be disabled in the sitemap as well, so I’d do well to just piggy back off of that.
So all I had to do was set the following in the my front matter
sitemap:
disable: true
and then configure the embedded RSS template1 to just range through pages that didn’t have that parameter set, like so …
{{- range where $pages "Sitemap.Disable" "ne" true }}
The original line would’ve been something like
{{- range $pages }}
You’ll need to create a new feed file by copying the contents of the embedded template to a file called rss.xml
in the layouts/_default/
directory
Once that’s done, all should be hunky dory.
Posts with this frontmatter, will now no longer appear in RSS feeds or the sitemap.
To make things simpler, I edited this sections archetype, so that the next time I create a new Notes & Miscellenea post, all of this metadata is already set for me.
Feedback on this post?
Mail me at feedback at this domain or continue the discourse here.
P.S. Subscribe to my mailing list!
Forward these posts and letters to your friends and get them to subscribe!
P.P.S. Feed my insatiable reading habit.
If you already have it defined in your theme, then override it. ↩︎