Some post dates are correct, most are Jan 1, 0001

I’m converting posts from Jekyll to Hugo. I wrote a script that ensures all the meta data dates are in the format YYYY-MM-DDTHH:MM-05:00. (Some were had just YYYY-MM-DD, other had the time too, and some were enclosed in quotes, some were not.) I’ve created new site and added the Strange Case theme. Using the example config.toml file, the date format is set like this:

DateFormat = "2 Jan 2006"

Some of the 276 posting I imported have the correct dates, but many - most - have Jan 1, 0001 as their date. I don’t understand why some posts would have the correct date, while others do not.

I should elaborate. This all happening locally when I run hugo server and visit localhost:1313. I haven’t gotten as far as publishing the site.

Have a look at Differing "Pages" between dev and production

I haven’t published the site, so I don’t have a dev environment versus a production one. I’m trying to migrate from Jekyll, and I don’t understand why the post date isn’t consistently handled.

You probably have pages without dates set. This is just a guess, however. It would be easier to help if we could see your code in a repo somewhere.

All of the posts have dates. All of the dates are complete.

But can’t you provide the repo…?

Huh, curiously one of the last commits on the theme was: “Further attempt to fix date format issue”. But the only issue I see is that it doesn’t seem to be using the .Site.Params.DateFormat anymore, so that config param is useless.

Taking this as an example, you are missing :ss (seconds) in the time component. Try the date as 2020-01-19T08:03:00-05:00 instead.

1 Like

Dis you read the post ? Solution is solving dates format problems

tryed to configure the date / time sources ?

I have refactored my script and now all the dates are properly formatted for Go / Hugo.

The date front matter on this site is a mismash of formats. Most have date and time. None of the times have seconds. Quite a few dates had either a single digit month or single digit day value. My script now properly deals with all those edge cases, and all 276 posts now have dates in a format Hugo expects.

Thank you everyone for your tips, questions, and suggestions. For the really curious, here is a link to the scripts I’ve created to convert my old postings to be used with Hugo. The site being converted is Eventually I’ll do the main site with its 2200+ postings. That site has more short code edge cases I’ll need to deal with in some fashion.

Thanks again.

1 Like