Item Posts showing in my archive

I have the following template to render my weblog archives:

{{ define "title" -}}
  {{ .Params.name }} | {{ .Site.Title }}
{{- end }}
{{ define "header" }}
  {{ partial "menu" . }}
{{ end }}
{{ define "main" }}
  <header>
    <h1>{{ .Title }}</h1>
  </header>
{{ range (where .Site.Pages "Section" "post").GroupByDate "2006" }}
  <h2>{{ .Key }}</h2>
  <ul>
    {{ range .Pages }}
      <li>
        <span>{{ .Date.Format "02 Jan" }}</span>
        <a href="{{ .Permalink }}" id="{{ .UniqueID }}" alt="{{ .Title }}">{{ .Title | markdownify }}</a>
      </li>
    {{ end }}
  </ul>
{{ end }}
{{ end }}
{{ define "footer" }}
  {{ partial "powered-by" . }}
{{ end }}

It worked perfectly on 0.18.1, but on the latest release has started showing a Posts at the most recent post (see https://collantes.us/archives/). How can I prevent that?

1 Like

It seems that if I do add after 1, I could solve the problem, like so:

 {{ range after 1 .Pages }}
      <li>
        <span>{{ .Date.Format "02 Jan" }}</span>
        <a href="{{ .Permalink }}" id="{{ .UniqueID }}" alt="{{ .Title }}">{{ .Title | markdownify }}</a>
      </li>
    {{ end }}

Is that the cleanest way to accomplish this?

Not tested, but I think you might be able to skip the after hack and switch to .Site.RegularPages. I’m guessing this is pulling the word “Posts” from the title of the section. .Site.RegularPages is just shorthand for .Site.Pages "Kind" "page"…

HTH.

1 Like

Where will .Site.RegularPages go? Thanks!

I think…

{{ range (where .Site.RegularPages "Section" "post").GroupByDate "2006" }}
2 Likes

It worked! Thanks mate, appreciated!

1 Like