Feeds

Feeds v1.0.3

This is a GoHugo theme component that implements various configurable feed formats. Currently implemented formats are RSS, Atom and JSONfeed.

Find out more about the RSS, Atom and JSON feed formats

Add this module
[[module.imports]]
path = "github.com/davidsneighbour/hugo-feeds"
disable = false
ignoreConfig = false
ignoreImports = false
Latest Version v1.0.3 (2022-09-01)
Fix to this version
hugo mod get github.com/davidsneighbour/[email protected]

ToDo

  • proper implementation of the formats
    • RSS
    • Atom
    • JSON feed
  • add hooks (for all feed formats or individual feed formats)
  • configurable section-, taxonomy- and term-feeds
  • partial to output list of available feeds on your website
  • proper testing, validation and dev-site

Configuration

Limits

hugo-feeds uses a cautious approach at configuring the output of the feeds. Where GoHugo’s internal RSS template prints all available pages without a configured limit, hugo-feeds will load only the 10 latest pages/posts, but you can configure at your pleasure.

If either rssLimit or services.rss.limit is defined and NOT overridden by any other configuration then these values will be chosen for RSS. Limits for specific feed formats can be configured explicitly.

1[dnb]
2  [dnb.feeds]
3    limit = 10
4    [dnb.feeds.atom]
5      limit = 10
6    [dnb.feeds.json]
7      limit = 10
8    [dnb.feeds.rss]
9      limit = 10
1dnb:
2  feeds:
3    atom:
4      limit: 10
5    json:
6      limit: 10
7    limit: 10
8    rss:
9      limit: 10
 1{
 2   "dnb": {
 3      "feeds": {
 4         "atom": {
 5            "limit": 10
 6         },
 7         "json": {
 8            "limit": 10
 9         },
10         "limit": 10,
11         "rss": {
12            "limit": 10
13         }
14      }
15   }
16}

Limits are formatted via integers. 0 disables, everything at 1 and over selects the last x items and -1 will list all items.

TODO: configuration

Posts to show in feeds

Set dnb.feeds.items to posts to show only items that are listed in params.mainSections in your feeds. All other values will result in all pages being included.

Discreet Drafts

Have a read through @zbetz’s great article Discreet Drafts in Hugo and rest assured that without configuration this module will hide all drafts (posts with draft in their frontmatter set to true) from it’s feeds. If you wish to force drafts being shown in the feeds then set dnb.feeds.drafts to true.

Hooks

hugo-feeds implements template hooks via hugo-hooks and makes the following hooks available:

Hook Description
feeds-init Hooks in after the opening tag. Do not open this to output anything. Just for initialising any of your plugins.
feeds-start Hooks in after the initial first tags that define your feeds purpose and before items of the feed are printed.
feeds-end Hooks in at the end of the feed after the items are printed.

All hooks exist in a second form containing the feed type and will run then only in that format. For example feeds-atom-init runs only at the init stage of the atom feed, feeds-rss-init in rss and feed-jsonfeed-init in JSONfeeds.