Skip to main content

Pretty Good Hat

Recent chat around micro.blog about enabling an “on this day” plugin prompted me to put together the shortcode below. Unlike sophisticated hugo configurations, mine is just updated by a cron job, so I can render it statically, without any javascript, and it’s always current to the day, even if I haven’t posted that day.

I call this shortcode from my /now page:

Posts on this day ({{ now.Format "Jan 2" }}):
<ul>
{{ range (where .Site.RegularPages "Section" "in" (slice "post" "note")) }}
  {{ if eq .Date.YearDay now.YearDay}}
  <li><a href="{{ .Permalink }}">{{ .Date.Format "2006-01-02"}} / {{ .Title }}</a>
  {{end}}
{{ else }}
    <li>... no entries ... 
{{ end }}
</ul>