Use custom page param inside .Paginator.Pages


I’m facing an issue on which I need help. My post markdown is as follows :

title: "Announcing a great conference"
eventdate: '2020-03-12'
date: '2020-02-21'
- conference
- culture
- society

Now, I can use .Params.eventdate in, say header.html, it works OK.

What does NOT work is in list.html :

        <div class="posts-list">
          {{ range .Paginator.Pages }}
            <article class="post-preview">
              <a href="{{ .Permalink }}">
                <h2 class="post-title">{{ .Title }}</h2>
                {{ if .Params.subtitle }}
                  <h3 class="post-subtitle">
                    {{ .Params.subtitle }}
                {{ end }}
                {{ if .Params.eventdate }}
                  *** THIS PART SHOULD DISPLAY BUT DOES NOT ***
                {{ end }}
          {{ end }}

If I replace .Params.eventdate with .Params.subtitle, .Params.tags, .Params.title… all these work OK. So why doesn’t my eventdate work ? I think it’s related to being inside of the {{ range .Paginator.Pages }}, but I may be wrong.

Thanks for any help on getting this working !

-> hugo env
Hugo Static Site Generator v0.66.0/extended linux/amd64 BuildDate: unknown

I don’t know, I can’t see your code. Share it, for great support! :sunglasses:

There are examples in the docs on how to do this:

Also for better assistance post a link to your repo next time, which is what @maiki is referring to :slightly_smiling_face:

  {{ if .Params.eventdate }}
                  *** THIS PART SHOULD DISPLAY BUT DOES NOT ***
    {{ end }}

The only reason I see that the above should not show is that the param eventdate isn’t set on that page.

A related tip would be to drop the quotes around the dates to get proper Go dates.

1 Like

Thanks for your replies. My repository was private but after all I see no reason not to open it, after all it is a public website.

Here it is, on line 43 :
If someone ever clones it be sure to checkout branch ‘eventdate’.

To reproduce, please go to http://localhost:1313/post/ and check that the words ‘NE MARCHE PAS’ aren’t displayed on the first post as I want them to be.

And to verify that eventdate really is set on that page, go to http://localhost:1313/post/2020-02-21-conference-gesticulee/ and check that the word ‘TEMPORAIRE’ appears in the title (as coded line 68 of this file)

No progress on my side…