Skip to content

Add RSS template that excludes "unlisted = true" posts#552

Open
ashton314 wants to merge 3 commits intoalex-shpak:mainfrom
ashton314:ashton/my-mods
Open

Add RSS template that excludes "unlisted = true" posts#552
ashton314 wants to merge 3 commits intoalex-shpak:mainfrom
ashton314:ashton/my-mods

Conversation

@ashton314
Copy link
Copy Markdown

This adds the default Hugo RSS template explicitly, and adds an option to exclude posts from the RSS feed.

(Idea from https://bphogan.com/2020/08/11/2020-08-11-creating-unlisted-content-in-hugo/)

Comment thread layouts/_default/rss.xml
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- $pages = (where $pages ".Params.unlisted" "!=" "true") -}}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the critical line that excludes unlisted posts from the RSS feed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this line be above the limit handling? To apply the limit only to listed pages.

@alex-shpak
Copy link
Copy Markdown
Owner

Hi!
Sorry, I kinda forgot about this PR. Do you think RSS format is still used around?

@ashton314
Copy link
Copy Markdown
Author

Do you think RSS format is still used around?

Absolutely! In the tech circles I hang out in, RSS is very much appreciated. In fact, if hugo-book didn't have RSS I wouldn't have begun to consider it.

@ashton314
Copy link
Copy Markdown
Author

I don't have terribly accurate metrics (by design; I don't want to track my readers) but I do know at least one person reads my blog via RSS. I would like to encourage more people to use RSS, so this is an important feature to me.

@alex-shpak
Copy link
Copy Markdown
Owner

I haven't used it in long time.
well, perhaps it is reasonable to use BookHidden param instead of unlisted, and to add rss config to the example site

[outputs]
  home = ['html', 'rss']

Otherwise looks alright, I would probably change layout a bit down the road

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants