List page publish date now defaults to that of the latest subpage

I see all my list pages have a value defined for PAGE.PublishDate when there shouldn’t be any. This seems to have changed in a recent version, but I don’t know which.

Repro for a new/blank site:

layouts/_default/list.html:

<html>
<body>
{{.PublishDate}}
</body>
</html>

layouts/_default/single.html:

<html>
<body>
{{.Title}}
{{.PublishDate}}
</body>
</html>

content/_index.md:

+++
title = "Main"
+++

content/foo.md:

+++
title = "Foo"
date = 2022-04-02T12:45:03-07:00
+++

http://localhost:1313/foo/ content:

Foo 2022-04-02 12:45:03 -0700 PDT

Expected http://localhost:1313 content:

0001-01-01 00:00:00 +0000 UTC

Actual http://localhost:1313 content:

2022-04-02 12:45:03 -0700 PDT

Currently limited git access so couldnt find that change. But I suppose that is rather a bug than intended behaviour

At least 125.3 behaves as you expect. Just a few versions to test in between to 128.2

1 Like

Looks like I was wrong and that is intended behaviour

A fix for this bug

Has been rolled out with 0.128.1

I would suppose that it behaved like that somewhere before…

Would be a remarkable thing for the Docs as usually frontmatter of pages do not affect the list page.

1 Like

@irkode Thanks, that does look like the change. This is unfortunate, because it forces a feed/atom/rss semantics onto list page dates instead of letting list pages act like every other page kind in this regard. It even contradicts the documentation. I will file an issue.

Reported: List page publish date now defaults to that of the latest subpage · Issue #12653 · gohugoio/hugo · GitHub

Copy of my argument:

The previous behavior (where PAGE.PublishDate worked like every other page kind) is better because:

  • It makes PAGE.PublishDate behave the same for all page kinds, which matches the current documentation. List pages can have a title, description, content, and front matter parameters of their own, and .PublishDate should reflect those parameters, like it does for the other page kinds.
  • The name “PublishDate” is unclear in the context of list pages: Is it the .PublishDate of the first page in the sub page list, or is it the publish date of the first published page (not including draft or expired pages or pages with future publish dates)?
  • The current behavior seems only suitable for feeds like Atom or RSS, where you would want to indicate the last change date for a section’s feed. The previous behavior is more suitable for HTML, where partial templates are reused across default templates like list.html and single.html (like displaying the .PublishDate). While feeds are important, HTML is by far the more common and important use case.
  • The current behavior can be computed manually and portably across modules/themes by ranging the sub-pages and tracking the latest .PublishDate, but the previous behavior (including the configured fallbacks in site config) cannot be done portably across modules/themes.
  • If enabling the current behavior really is desirable, it can be done with a new field instead, which is time.Time{} for non-list pages.

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