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.