I’ve found heaps of seemingly outdated posts about this, and I can’t find anything of use in the Hugo docs. What am I meant to actually type?
Could you please be more precise what you mean with:
change the date on my posts
it’s a big difference if
- just format of new posts?
or - migrate your posts?
also the variant ISO 8601? (exact format you need
an example could also help to catch the audience
- whats your config
- where are your dates
Both?
Doesn’t have to be ISO 8601 specifically, I just don’t want the American format, and ISO 8601 is a standard.
I encourage you to take a squiz at the recent commit history. I feel like I’ve tried everything.
hugo.toml
[params]
dateFormat = "2006-01-02"
Then in your templates.
{{ .Date.Format site.Params.dateFormat }}
If you wish to localize (format + translate) a date, use the time.Format
function with a localization token:
{{ .Date | time.Format ":date_medium" }}
Short Answer:
read your Theme Docs and examples → WonderMod → PaperMod → Installation · adityatelange/hugo-PaperMod Wiki · GitHub
params:
dateFormat: "MYDATE 2006-01-02 MYDATE"
will be picked automatically from your theme
DOSBox
MYDATE 2024-03-19 MYDATE · 6 min · 1192 words · mindlux | Suggest Changes
Last updated on MYDATE 2024-03-26 MYDATE
<tl>;<tr>
The date is an attribute in your Frontmatter of all pages. It is set when you create a new page using hugo new content
It will be taken from `archetypes\default.md and is defined as:
---
date: {{ .Date }}
---
When generating the site your Theme formats this value using
\themes\WonderMod\layouts\partials\post_lastmod.html
\themes\WonderMod\layouts\partials\post_meta.html
there’s a code inside that formats according to the mentioned config option from the top.
{{- $scratch.Add "meta" (slice (printf "<span title='%s'>%s</span>" (.Date) (.Date | time.Format (default "January 2, 2006" site.Params.DateFormat)))) }}
But when I change the date in these files (as you could see now):
Such as you listed here:
Nothing changes.
P.S. Thank you for your time, that looked like it took an amount of effort to go through.
@irkode already answered your question.
If I clone your site, then add this to the site config under the params key…
dateFormat: 2 January 2006
…this is what I see when I build your site:
Sry for the confusion
The code refernences where just explainatory.
Leave the theme alone and configure it using the value in your config file.
Updated the solution ro make it clearer
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.