I would like an indication on my site of the exact date and time when Hugo built the site. So I tried using .PublishDate, but it always shows up as 0001-01-01 00:00:00 +0000 UTC. How can I get the correct publish date? Thanks!
Publish date is based on the date you set in frontmatter of your posts. This indicates that it isn’t set.
For build date, see:
http://discuss.gohugo.io/t/how-to-get-a-footer-with-build-time
I’m having a similar issue.
Given the following frontmatter:
+++
Homepage = ""
Title = "rainbow dash"
Twitter = ""
date = "2016-12-08T20:55:58-06:00"
type = "speaker"
+++
The value returned by {{ .PublishDate }}
is 0001-01-01 00:00:00 +0000 UTC
I understand that this is the result of date being set incorrectly (or rather, not set at all), but I can’t figure out how it’s not set?
My guess is:
- We silently ignore errors from date parsing, see the formats here: https://github.com/spf13/cast/blob/24b6558033ffe202bf42f0f3b870dcc798dd2ba8/caste.go#L499
- We are generally liberal with date formats, and I’m not sure what, if any, is wrong with yours
- Using a proper TOML date (i.e. no quotes) may give you more feedback
I would agree, although date
in that case is not being set by me, but by hugo new
.
One a whim, I did try to remove the quotes (although they were added by hugo new
, and it didn’t seem to make any change.
Try using pubdate = 2016...
Date and PublishDate are two different things.
I get this date in taxonomy URL
This is what I get in sitemap.xml
<url>
<loc>http://example.com/tags/</loc>
<lastmod>0001-01-01T00:00:00+00:00</lastmod>
<priority>0</priority>
</url>
Have you tried {{ .Now }}
?