hugo で特定の記事を noindex にしたり、rss に表示しないようにする

soh335.hatenablog.com

こういうどうでもいい記事は noindex になってても良いし、もっとどうでもいい記事*1rss に表示されなくても良い。

自分で(ある程度)手をいれることが出来れば特定の記事を noindex にしたり rss に表示しないことも出来る。今回も hugo で考える。

記事の template や rss の template で記事のパラメータを使うことが出来るので

    {{ range first 15 (where .Data.Pages "Section" "!=" "hoge") }}
    <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>{{ .Content | html }}</description>
    </item>
    {{ end }}

こうすれば hoge という section 以外を rss に表示することが出来る *2

*1:他人に見せる必要のない記録とか

*2:where は key となる値に intersect 以外は配列を使えないので tag 等で filter は現状出来ない。 Hugo - Hugo Template Functions そして、特定の section, tag は rss を作らないということも出来ない。