Blog date 06 january 0001 showing up in one blog, not the other

Two blog entries, same front matter format but different date values, same layout - one shows correct date and one shows 06 Jan 0001.

Can’t figure it out.

Site here:

https://contivpp.io/blog/

-cm

Share your site code so that we can see how your dates are being formatted.

1 Like

sorry, wrong link sent. here you go:

tx a million

The date format you specified is not valid: https://github.com/contivpp/contivpp-site/blob/master/config.toml#L51

You have:

dateFormat = "6 January 2006"

But it should be:

dateFormat = "2 January 2006"

See the docs on hugo date formatting for valid inputs

added suggested dateFormat and same result. I ended up cleansing the browser cache and “seems” that
fixed problem with and without suggested dateFormat statement in config.toml. Not sure.

But will triple-check docs and experiment b4 any door knocks for help.

really appreciate super-quick response.

Hugo is awesome!!

If you don’t specify a dateFormat in your config file, then it will default to "Jan 2, 2006"

You can see where this happens in your single blog template: https://github.com/contivpp/contivpp-site/blob/master/layouts/blog/single.html#L20

yes was looking at that closely. but the first one blog worked okay and the second one was incorrect so thought it might be something in front matter of the one that did not work.

If I’m not mistaken, your front matter dates must be in the form of YYYY-MM-DD

A good way for me was to define all needed date formats in the config file like this

[Params]
    dateFormatLong      = "2006-01-02 15:04"
    dateFormatShort     = "2006-01-02"
    dateFormatYear      = "2006"
    dateFormatFeed      = "2006-01-02T15:04:05Z"

With using in the templates

{{.Site.LastChange.UTC.Format .Site.Params.dateFormatFeed }}

or

{{ .PublishDate.UTC.Format .Site.Params.dateFormatFeed }}

It helps me to go around spelling errors.

1 Like