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.
[EDIT]
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.
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.
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.
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. https://github.com/zanshin/jtoh.git. The site being converted is https://music.zanshin.net. 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.