As if I didn’t have enough with fixing and tweaking my blog recently… Maybe it just gave me an appetite. With a bit of help from Claude (mostly as a pointer) I added two microhooks to my blog:

layouts/partials/microhook-post-list-byline.html and layouts/partials/microhook-post-byline.html

These change the date from the standard, nice American format to the ISO format, which I prefer (as was the case on my old blog). Computer folks should feel right at home, but for most of you, this may be a bit jarring, but not too hard to get used to. I hope.

The Hugo code for that (including a link that opens the post in its dedicated file):

layouts/partials/microhook-post-list-byline.html

    <a href="{{ .Permalink }}" class="post-date u-url dt-published"><time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2006-01-02" }}</time></a>

layouts/partials/microhook-post-byline.html

    <a href="{{ .Permalink }}" class="post-date u-url dt-published"><time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2006-01-02" }}</time></a>

The key that I forgot is that the .Date.Format elements actually need to use the year 2006. Why, well, I didn’t get it from the docs, but this Stack Overflow post explains it in a way I can follow better: the different elements of the date have saved locations defined by number:

    Mon Jan 2 15:04:05 -0700 MST 2006
    0   1   2  3  4  5              6

So 0 is for the day, which is Monday, Jan is for the month, which is 1… It kind of adds up, but still doesn’t. I need my coffee.