Skip to content

Commit

Permalink
Add new front matter 'nofeed' for RSS feeds
Browse files Browse the repository at this point in the history
 1. 'nofeed' is a boolean (true or false)
 2. use it for content that should not show up in the RSS feed
 3. 'layouts/index.xml' is easy to modify
  • Loading branch information
dataCobra committed Dec 23, 2019
1 parent f244a1a commit 4aec26a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -21,6 +21,7 @@ For more explanation about some features, scroll down to **Features**
* **(+)** New list of all taxonomies and tags below the post in single view
* **(+)** New array front matter notaxonomy
* **(+)** Author/Writer display in post with extra features
* **(+)** New bool front matter nofeed
* Multilingual support for month names
* Syntax highlighting
* Custom CSS
Expand Down Expand Up @@ -195,6 +196,16 @@ website.

All content that has no author set, will not use this feature obviously.

### Front matter "nofeed" for RSS

If you have pages, posts or other content that should not show up in the RSS
feed of your website. You can set the new front matter `nofeed` for this
content. It's a boolean, you could use either `true` or `false`.

If you want to modify the `index.xml` layout. Copy the Vitae layout from
`hugo-vitae/layouts/index.xml` to your Hugo site root directory into the
folder `layouts/` and change it the way you want.

## Credits

* [hugo-ink](https://github.com/knadh/hugo-ink) from which Vitae was forked
Expand Down
29 changes: 29 additions & 0 deletions layouts/index.xml
@@ -0,0 +1,29 @@
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end }}
{{ range .Site.RegularPages }}
{{- if ne .Params.nofeed true -}}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>{{ .Summary | html }}</description>
</item>
{{ end -}}
{{ end }}
</channel>
</rss>

0 comments on commit 4aec26a

Please sign in to comment.