On This Day


I am trying to figure out how to make On This Day with my current theme. As far as I understand the Micromeories code just discovers and crawls your /archive page and populates the content, so as long as you have an /archive page, in theory, and as I barely understand it, should work. It was working on the first iteration of the theme (Outpost), then it stopped. On the second iteration of the theme, all that was added was support for clickable categories links.

So, again, I am trying to figure out or understand what I may need to change (or add) in the theme’s template to make it work again.


The theme needs to include the dt-published microformat in the template for single posts. So, on this page, for example, instead of

<p class="u-url date">Friday October 20, 2023</p>

you should have something like

  <time class="dt-published" datetime="2023-10-20T14:03:28-0600">Friday October 20, 2023</time>

Ha! That’s all there is to it? I’ll try it when I get home. Thank you!

Can’t promise you that 100%, I only executed the Python code in my brain, not on an actual computer. :blush: But it looks like it should be alright if you add dt-published to the post template.

Just to make sure I wont be braking anything important, this is how it currently is in the template.

<p class="u-url date">{{ .Date.Format "Monday January 2, 2006" }}</p>

I should change it to

<p class="dt-published">{{ .Date.Format "Monday January 2, 2006" }}</p>

or exactly as you described up there?

You can always revert your changes if something breaks. I think you need my version, though.

What’s there already is a bit weird, as it is marked up as a URL when it’s not. :slight_smile:

Okay, And I don’t change anything from your script above? I copied and pasted it exactly as is, and “it works” is just weird. It labels every post as of October 20, 2023, but also, I am not sure if the posts showing are actually from 10/23 of previous years.

Thank you, again!

You need to use the go convention for time. I also wouldn’t use a <p> class for time. Instead, I’d do the following:

  class = "date dt-published"
  datetime = "{{ .Date.Format "January 02, 2006 15:04:05  -0700" }}" >
    <a class = "u-url" href= "{{ .Permalink }}">
      {{ .Date.Format "Monday January 2, 2026" }}

Thank you, Jason, I’ll try it. :smiley:

Hello, something happened. Did something change on Micro.blog recently? I managed to create a custom theme to “fix” on this day with this theme and it was working but now I get invalid dates with the posts.

Is there anything I need to do to fix it?

This almost always is an issue where you formatter is defined wrong for Hugo. Without seeing code, it’s hard to help debug. The format always has to be like what I put above – it’s “numeric” order kind of… Month Day Hour Minute Second Year Timezone… always has to be 01 for month, 02 for day, 03 for hour, 04 for minute, 05 for second, 06 for year, and 07 for timezone, whatever your desired date format. Day is always Monday.

So for today in your format, it has to be {{ .Date.Format "Monday January 2, 2006" }}

The error was I my code where I had a typo and wrote 2026 by mistake from my iPad on the prior post.

Ah! Gotcha, I’ll fix it in my template. Thank you!

Okay, it is fixed in post, if you go to my on this day page though, I still see invalid date but when you go into the post it shows the correct date.

This is the code I have in layouts/post/single.html template.

  class = "date dt-published"
  datetime = "{{ .Date.Format "January 02, 2006 15:04:05  -0700" }}" >
    <a class = "u-url" href= "{{ .Permalink }}">
      {{ .Date.Format "Monday January 2, 2006" }}

My guess is that you need to do a full rebuild.

Or not use this hack with this theme :sweat_smile:

The rebuild fixed it :slight_smile: