Sitemap.Disable (working) but Rss.Disable (not) - internal issue?

I been using this approach

To exclude files from Sitemap.

I got my internal method to exclude some files from RSS template but as the above is neat, I want to simplify my code instead of ranging and excluding by if.

The problem I am facing is that this:

{{- range where $pages "Sitemap.Disable" "ne" true }}

with this in front matter:

---
sitemap:
  disable: true
---

Working well. This is used in my sitemap file with

{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}

on front and later

{{ range where $pages "Sitemap.Disable" "ne" true }}

But, if I want to implement same approach in my rss.xml file, this do not work:

{{- $pctx := . }}
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
{{- $pages := slice }}
{{- if or $.IsHome $.IsSection }}
{{- $pages = $pctx.RegularPages }}
{{- else }}
{{- $pages = $pctx.Pages }}
{{- end }}
{{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }}
{{- $pages = $pages | first $limit }}
{{- end }}

later

{{ range where $pages "Rss.Disable" "ne" true }}

and in front matter

---
rss:
  disable: true
---

Interesting is if I put this:

{{ range where $pages "Sitemap.Disable" "ne" true }}

and update frontmatter, it working.

Is there a parameter RSS in collision with some internal templating and this is the reason why is not working?

.Params.rss.disable

And you probably want to get into the habit of placing custom front matter fields under the params key:

params:
  rss:
    disable: true
2 Likes

That’s make sense :slight_smile:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.