Error with time.Format

I am getting the following error during the build process.

WARN 2023/01/06 14:51:07 .File.UniqueID on zero object. Wrap it in if or with: {{ with .File }}{{ .UniqueID }}{{ end }}
Error: Error building site: failed to render pages: render of "page" failed: "/home/runner/work/archdocs/archdocs/layouts/docs/single.html:5:42": execute of template failed: template: docs/single.html:5:42: executing "main" at <time.Format>: error calling Format: unable to cast <nil> of type <nil> to Time
Total in 2364 ms
Error: Process completed with exit code 255.

My code is below for single.html.

{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ if isset .Params "servicenowprj"}}
<left><p><font color="#474c55"><b>Author:</b> {{ .Params.author }} | <b>Version:</b> {{ .Params.version }} | 
	<b>Created on:</b> {{ .Params.date | time.Format ":date_short" }} | 
	<b>Last Modified:</b> {{ .Params.lastmod | time.Format ":date_short" }} | 
	<b>ServiceNow PRJ#:</b> {{ .Params.servicenowprj }}</font></p></left>
{{ else }}
<left><p><font color="#474c55"><b>Author:</b> {{ .Params.author }} | <b>Version:</b> {{ .Params.version }} | 
	<b>Created on:</b> {{ .Params.date | time.Format ":date_short" }} | 
	<b>Last Modified:</b> {{ .Params.lastmod | time.Format ":date_short" }}</font></p></left>
{{ end }}

<div class="td-content">{{ .Content }}</div>

{{ partial "page-meta-lastmod.html" . }}

{{ end }}

This works with ‘hugo server’ for testing, but does throw the error. When building for deployment though, it fails and doesn’t complete.

Ok, I fixed it, but don’t understand why I’m getting the error. In the frontmatter of a new file, I have a single digit for the date “2023-1-6”.

---
title: "Research DR"
date: "2023-1-6"
lastmod: "2023-1-6"
author: "TBD"
version: "0.1"
servicenowprj: "N/A"
draft: "false"
---

If I change the date in lastmod to “2023-01-06”, the build works successfully, but I still get the following error. “WARN 2023/01/06 09:16:58 .File.UniqueID on zero object. Wrap it in if or with: {{ with .File }}{{ .UniqueID }}{{ end }}”.

you can define the date handling in the config file

my looks like

[frontmatter]
date                       = [ "date", ":filename", ":default"]
publishDate                = [ "publishDate", "date"]
lastmod                    = [ ":git", "lastmod", ":fileModTime", "publishDate"]
expiryDate                 = [ "expiryDate"]

this is the doc

One of pages that exercises this code is not backed by a file. That includes lists pages that are automatically generated for top level sections, taxonomy pages, and term pages.

That is why you need to code defensively:

{{ with .File }}
  {{ .UniqueID }}
{{ end }}

So search your code for .UniqueID.