But since it doesn’t behave the same way for all the dates even though all of them are in the same format, I suspect it is a bug, so it would be better to fix it globally (in Hugo itself) rather then tinkering with local templates.
That doesn’t feel right, because in case when the date timezone matches the system timezone the output is 2020-06-29 13:33:23 +0200 CEST, which is correct, so it seems to understand the date even with no formatting provided, and it even adds a nice CEST timezone abbreviation (which your example format does not).
When a format string is not provided, we fall back to 2006-01-02 15:04:05 -0700 MST. Note that both an offset and abbreviation are provided.
When the offset is the same as your current time, the local abbreviation for the offset is displayed. Why? I don’t know; I’m not sure it is the right thing to do. Keep reading…
When the offset is different than your current time, we have no idea what abbreviation to display, so we display the offset again, which is why it looks like it is printed twice.
There is not a 1:1 relationship between offsets and abbreviations. For example, my current offset of -04:00 could be any of the following: AMT, AST, AT, BOT, CDT, CIDST, CLT, EDT, FKT, GYT, PYT, Q, or VET.
For example: if you authored a page with a -04:00 offset, which timezone abbreviation would you want displayed? Cayman Islands Daylight Saving Time (CIDST)? Falkland Island Time (FKT)? Maybe Guyana Time (GYT)? None of those make sense to me. I’m in Eastern Daylight Time (EDT). They’re all -04.00.
The abbreviation is tied to the TZ environment variable on the machine where Hugo is running. If I change my TZ environment, then run hugo again, I will get different results.
Avoid the confusion. Format your dates, and rely on offsets rather than abbreviations.
Thank you for such a detailed explanation, it all makes sense to me now. Yes, I will rely on explicit date format from now on.
Just one thing though:
When the offset is different than your current time, we have no idea what abbreviation to display, so we display the offset again, which is why it looks like it is printed twice
Perhaps, it would be better then just not to print the offset second time. I mean, that’s was the only reason why I suspected a bug here - it just doesn’t look right.