Some of my posts are lists of cases, which change over time. Ideally, I want each post to show when I created the original post and when I updated it.
PaperMod’s
layout for post metadata, layouts/partials/post_meta.html
, does not
include the date the post was last modified. Fortunately, Hugo has a
predefined frontmatter variable,
lastmod,
which allows an author to store that data.
Even better, Hugo’s Git integration can derive the lastmod
value
from the file’s Git history.
Hugo will automatically pull the lastmod
value from the Git history,
but the author can manually override the lastmod
value in the frontmatter.
Mert Bakir
wrote a great post about integrating the two approaches.
I adapted the solution in PaperMod. Firest, I added this key to config.yaml
:
|
|
Next, I copied the theme’s layouts/partials/post_meta.html
to
my project folder and modified it.
The code below displays the lastmod
date only if it differs
from the frontmatter date
.
|
|
It works great.