{{- $posts := where .Site.RegularPages "Section" "posts" -}}
{{- if $posts -}}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>{{ .Site.Title }}</title>
    <link>{{ .Site.BaseURL }}</link>
    <description>{{ .Site.Params.description }}</description>
    <generator>Hugo -- gohugo.io</generator>
    {{ with .Site.LanguageCode }}<language>{{.}}</language>{{end}}
    <lastBuildDate>{{ (index $posts 0).Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</lastBuildDate>
    {{- with .OutputFormats.Get "RSS" -}}
    <atom:link href="{{ .Permalink }}" rel="self" type="{{ .MediaType }}"/>
    {{- end -}}
    {{- range first 20 $posts -}}
    <item>
      <title>{{ .Title }}</title>
      <link>{{ .Permalink }}</link>
      <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</pubDate>
      <guid isPermaLink="true">{{ .Permalink }}</guid>
      <description>{{ .Summary | plainify | truncate 200 }}</description>
      {{- if .Params.categories -}}
      {{- range .Params.categories -}}
      <category>{{ . }}</category>
      {{- end -}}
      {{- end -}}
      {{- if .Params.tags -}}
      {{- range .Params.tags -}}
      <category>{{ . }}</category>
      {{- end -}}
      {{- end -}}
    </item>
    {{- end -}}
  </channel>
</rss>
{{- end -}}
