Year string broken on multipages

This works on single pages to add ordinal date suffixes -nd, -rd, -st, or -th.

{{ humanize .Page.PublishDate.Day }} {{ .Date.Format "Jan, 2006" }}

But on multipages, the year is broken and returns a string 0001. (Test with the linked example).

If you are referring to this…

…then access the section values via the root context:

{{ range $paginator.Pages }}
  {{ if eq $paginator.PageNumber 1 }}
    <h1>{{ $title }}</h1>
  {{ else }}
    <h1>{{ $title }} (continued)</h1>
  {{ end }}
  {{ humanize $.PublishDate.Day }} {{ $.Date.Format "Jan, 2006" }}
  {{ .Content }}
{{ end }}


I redid this to make one date (or meta) partial that can be used across multiple areas without the error. It was a learning experience on the scope and the dot and the dictionary aspects.

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