Context
I am trying to port an existing Jekyll site to Hugo. I have two sections, “microblog” for short-form posts and “writing” for long-form posts.
Here are the relevant parts of my config.toml
:
[mediaTypes."application/atom+xml"]
suffixes = ["xml"]
[outputFormats.atomfeed]
mediaType = "application/atom+xml"
baseName = "feed"
isPlainText = true
[outputFormats.jsonfeed]
mediaType = "application/json"
baseName = "feed"
isPlainText = true
[outputs]
home = ["html"]
section = ["html", "atomfeed", "jsonfeed"]
I currently have the following layout files, which correctly generate both Atom and JSON feeds for both sections (I realize both sections could share one pair of default list layout files, but that doesn’t make a difference for this question):
- layouts/writing/list.atomfeed.xml
- layouts/writing/list.jsonfeed.json
- layouts/microblog/list.atomfeed.xml
- layouts/microblog/list.jsonfeed.json
This configuration/set of layouts correctly generates RSS/Atom feeds for each section in the root folder:
- /microblog.xml
- /writing.xml
- /microblog.json
- /writing.json
First Question
The generated feeds are named/located differently than they were for the existing Jekyll site. Ideally, I wouldn’t need to use server-side redirects to preserve the old URLs, but I can’t figure out how to use Hugo Aliases to achieve this, since Aliases can seemingly only appear in front matter for actual content, and have no effect on list layouts.
Ideally the files would instead be generated in the following locations (after the arrows):
- /microblog.xml -> /microblog/feed.xml
- /writing.xml -> /feed.xml
- /microblog.json -> /microblog/feed.json
- /writing.json -> /feed.json
How can I change the location(s) of the generated feeds on a per-section basis?
Second Question
Assuming it’s possible to do the above, I also want to generate 4 feeds for the microblog
section rather than 2: JSON and Atom feeds for all posts, as well as JSON and Atom feeds for a specific subset of posts that could be filtered using a range with a where
function.
It seems like only one rendered list (feed) can be generated per section per defined output format. I could make two additional dummy output formats to generate the two additional filtered feeds, but then those will be generated for both sections, when I only want it done for the microblog
section. Is there a cleaner way to render multiple feeds for a single section?