With Hugo, I'm creating a blog in french. Currently all my date are displayed in english (february) but I want them to be displayed in french (février). How to set the language ?
My config.toml looks like this:
baseURL = 'http://example.org/'
languageCode = 'fr-FR'
defaultContentLanguage = "fr"
defaultContentLang = "fr"
title = 'TITLE'
theme = "THEME"
I try to set languageCode, defaultContentLanguage and defaultContentLang to fr but with no success.
I don't need multi language support, I just only need french.
CodePudding user response:
To use localization, you need to use the Hugo function time.Format (which has an alias dateFormat). It takes two parameters:
- desired format
- time.Time object, or timestamp
Example:
{{ time.Format "Jan. 2, 2006" .Date }}
or
{{ dateFormat "Jan. 2, 2006" .Date }}
Docs: https://gohugo.io/functions/dateformat/
The .Format method (e.g. {{.Date.Format "Jan. 2, 2006}}) will not apply the desired localization.
