Date vs Publishdate

Want to show “NEW” next to articles that have been published recently, but I also want to show the date the events happened. So I saw in the manual that there are two date available in the front matter: date and publishdate.

I can successfully do this based on “.Date”:

{{ if (lt .Now.Unix (add .Date.Unix 904800)) }}<em>NEW</em>{{ end }}

but I can’t use “publishdate” in the same manner.
Can I have some param that is treated as a date in the content list?

Date and PublishDate are both of type time.Time. I don’t see why PublishDate wouldn’t work for you. Are you setting pubdate or publishdate in the front matter?

I am probably doing it wrong. How should I call it in this case?

date = "2011-09-12T16:48:46+02:00"
publishdate = "2015-11-12T16:48:46+02:00"
title = "Pretī Āfrikai"
trip = "Maroka"

and in my list file:

    {{ partial "head.html" . }}
{{ partial "header.html" . }} {{ if isset .Site.Params "description" }} {{ end }}
{{ range .Data.Pages.GroupByParam "trip" }}

{{ .Key }}

    {{ range .Pages.Reverse }}
  • {{ .Title }} {{ if (lt .Now.Unix (add .Publishdate.Unix 904800)) }}NEW{{ end }}
  • {{ end }}
{{ end }}
{{ partial "footer.html" . }}

Which gives the error:

ERROR: 2015/11/12 Error while rendering homepage: template: theme/index.html:17:44: executing "theme/index.html" at <.Publishdate.Unix>: Publishdate is not a field of struct type *hugolib.Page

It’s .PublishDate not .Publishdate.

Thank you, that was quite easy to solve. I thought I tried it before, but oh well :slight_smile:
Hugo is awesome, and the community here too!