Skip to content

Commit 4c82ea8

Browse files
authored
Merge pull request #325 from Vimux/localize-post-meta-dates
Localize post meta dates
2 parents 81795f3 + 872c006 commit 4c82ea8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

‎exampleSite/content/docs/customization.md

+10
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ Full list of available default post meta fields:
8080
In addition to the default meta fields, you can add your own by placing a custom partial under
8181
`layouts/partials/post_meta/<name>.html`.
8282

83+
#### Post meta: `date` localization
84+
85+
With [Hugo v0.87.0](https://gohugo.io/news/0.87.0-relnotes/) (or later), `date` meta field shows localized dates (with
86+
weekdays and months in the current language) by default. In most cases, such a transition is painless, but owners of
87+
multilingual sites should be careful and check that everything translates as expected after the upgrade.
88+
89+
You can also use a predefined layout, like `:date_full`, and it will output localized dates or times. For additional
90+
information about localized dates and possible date/time formatting layouts, please see
91+
[Hugo: time.Format](https://gohugo.io/functions/dateformat/).
92+
8393
### Thumbnail visibility
8494

8595
By default, a thumbnail image has shown for a list and single pages simultaneously. In some cases, you may want to show

‎layouts/partials/post_meta/date.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<div class="meta__item-datetime meta__item">
33
{{ partial "svg/time.svg" (dict "class" "meta__icon") -}}
44
<time class="meta__text" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
5-
{{- .Date.Format (.Site.Params.dateformat | default "January 02, 2006") -}}
5+
{{- .Date | dateFormat (.Site.Params.dateformat | default "January 02, 2006") -}}
66
</time>
77
{{- if ne .Date .Lastmod }}
88
<time class="meta__text" datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}">(
9-
{{- T "meta_lastmod" }}: {{ .Lastmod.Format (.Site.Params.dateformat | default "January 02, 2006") -}}
9+
{{- T "meta_lastmod" }}: {{ .Lastmod | dateFormat (.Site.Params.dateformat | default "January 02, 2006") -}}
1010
)</time>
1111
{{- end -}}
1212
</div>

0 commit comments

Comments
 (0)