Page is sticky in RSS Feed

Since multipages use _index.md, they always appear at the top of the RSS feed, even when new content is added (this also happens with site.Pages where sections appear before regular pages). Any way to prevent this?

Probably. You will have to show a sample. My guess is, that the frontmatter is doing something that makes it sticky.

Clone the linked example in my first comment, then create a new rss.xml file inside it in layouts/_default with the code below. Now open the /index.xml file and see. Even if you change the date of any other file to a more recent one, the multipage post (post 8) remains at the top.

Summary
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $p1 := $pctx.RegularPages -}}
{{- $p2 := where $pctx.Pages "Layout" "multipage" -}}
{{- $pages = $p1 | union ($p2) -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- 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 $pages }}
    <item>
      <title>{{ .Title }}</title>
      <link>{{ .Permalink }}</link>
      <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
      {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
      <guid>{{ .Permalink }}</guid>
      <description>{{ .Summary | html }}</description>
    </item>
    {{ end }}
  </channel>
</rss>

The content in RSS will show on the top when it’s the latest. See what’s the lastmod or publishDate for them. You you don’t have, than probably it’s taken from system when site is generated.

See my previous comment.

Could you post a link to live rss where issue is shown.

Here (check dates of post 8 and 9).

See here. Is the order correct?
Second, see what year is showing for pages at the booth.


Order is correct in your case, as I also found out with an RSS previewer. The problem is with the service I use to send out my RSS newsletter (Mailerlite) which uses the RSS feed order as it is, with the _index.md page at the top. I would guess a service like Mailchimp would also behave the same.

Make sure they got dates set correctly <pubDate> and will more likely work with everything.

My bad! The pages needed to be sorted by date and in reverse
{{- $pages = $pages.ByDate.Reverse }}

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