When seeting publish date to `:git`, uncommited pages do not render

[frontmatter]
  publishDate = [':git', 'date' ]

I have an event calendar as a website, and it does not make sense to separately track the time from the event from the time of publishing, but it is useful to have that timestamp for atom feeds, ical, etc.

However, setting this value causes pages which are not committed to silently not render, which makes adding new events and confirming they show up correctly frustrating. There should be an error if a page that exists will not render at all.

I was hoping to fix this like so:

[frontmatter]
  publishDate = [':git', 'date', ':fileModTime' ]

But even adding date to the frontmatter will not cause the page to render.

Use the --buildFuture flag.
https://gohugo.io/commands/hugo/

I never needed that flag when I wasn’t using the publish date, the only reason I am really using it is for the atom feed’s <published> field now.

Post your front matter for the page you’re having a problem with.

hugo.toml:

[frontmatter]
  date = ['date', 'start']
  lastmod = [':git']
  publishDate = [':git', 'date' ]

The section template:

{{ define "main" }}
  <ol class="event-list">
    {{- range sort .Pages "Params.Start" "desc" }}
    <li class="event">
      {{ partial "event" . }}
    </li>
    {{- end }}
  </ol>
{{ end }}

Here is the patch adding the new file:

diff --git a/content/events/test.md b/content/events/test.md
new file mode 100644
index 0000000..7e2c974
--- /dev/null
+++ b/content/events/test.md
@@ -0,0 +1,8 @@
++++
+title = "Uncommitted test event"
+start = 2026-03-02T00:00:00
+end = 2026-03-02T01:00:00
+description = """
+This event does not make it to `.Pages`
+"""
++++

And the frontmatter

+++
title = "Uncommitted test event"
start = 2026-03-02T00:00:00
end = 2026-03-02T01:00:00
description = """
This event does not make it to `.Pages`
"""
+++

Using --buildFuture does seem to work cause errors to appear regarding missing dates when rendering partials since I removed the UTC timezone for the dates in the test example. It seems counter intuitive that this is required though when I haven’t specified a real date at all

I am unable to reproduce the problem.

hugo.toml

[frontmatter]
  date = ['date', 'start']
  lastmod = [':git']
  publishDate = [':git', 'date' ]

content/example.md (not committed as you mentioned):

+++
title = "Uncommitted test event"
start = 2026-03-02T00:00:00
end = 2026-03-02T01:00:00
description = """
This event does not make it to `.Pages`
"""
+++

When I run hugo server --buildFuture I see this:

[frontmatter]
  date = ['date', 'start']
  lastmod = [':git', ':fileModTime' ]
  publishDate = [ ':git', ':fileModTime' ]

This works for me now without --buildFuture

With this project configuration:

[frontmatter]
  date = ['date', 'start']
  lastmod = [':git']
  publishDate = [':git', 'date' ]

…and this this front matter:

+++
title = "Uncommitted test event"
start = 2026-03-02T00:00:00
end = 2026-03-02T01:00:00
description = """
This event does not make it to `.Pages`
"""
+++

…the publishDate for the uncommitted file will be the start date, which is in the future.

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