Dates

Screenshots

Default date format:

Oct 19, 2021

Default date format when date != lastmod:

Last updated on Oct 30, 2020

My preferred yyyy-mm-dd format:

2021-10-19

My preferred date format when date != lastmod.

2010-05-08 / updated 2020-10-30

Site date_format parameter

In config/_defaults/params.yaml.

Default:

date_format: 'Jan 2, 2006'

Custom:

date_format: '2006-01-02'

Template override

This is the changes I made in my site’s layouts/partials/page_metadata.html template override.

diff -u /home/alex/Code/{External/wowchemy-hugo-modules/wowchemy,Personal/blogue}/layouts/partials/page_metadata.html
--- /home/alex/Code/External/wowchemy-hugo-modules/wowchemy/layouts/partials/page_metadata.html 2021-10-30 22:56:06.876349037 -0400
+++ /home/alex/Code/Personal/blogue/layouts/partials/page_metadata.html 2021-10-30 23:36:03.862866240 -0400
@@ -15,15 +15,15 @@
 
   {{ if not (in (slice "event" "page") $page.Type) }}
   <span class="article-date">
-    {{ $date := $page.Lastmod.Format site.Params.date_format }}
     {{ if eq $page.Type "publication" }}
-      {{ $date = $page.Date.Format (site.Params.publications.date_format | default "January, 2006") }}
+      {{ $page.Date.Format (site.Params.publications.date_format | default "January, 2006") }}
     {{ else }}
+      {{ $page.Date.Format site.Params.date_format }}
       {{ if ne $page.Params.Lastmod $page.Params.Date }}
-          {{ i18n "last_updated" }}
+        / updated
+        {{ $page.Lastmod.Format site.Params.date_format }}
       {{ end }}
     {{ end }}
-    {{ $date }}
   </span>
   {{ end }}

GitHub issue

https://github.com/wowchemy/wowchemy-hugo-themes/issues/2064

Previous
Next