date - 雨果,如何设置日期语言

标签 date hugo

在 Hugo 的帮助下,我正在创建一个法语博客。 目前我所有的日期都以英语(二月)显示,但我希望它们以法语(février)显示。 如何设置语言?

我的 config.toml 看起来像这样:

baseURL = 'http://example.org/'
languageCode = 'fr-FR'
defaultContentLanguage = "fr"
defaultContentLang = "fr"
title = 'TITLE'
theme = "THEME"

我尝试将 languageCodedefaultContentLanguagedefaultContentLang 设置为 fr 但没有成功。

我不需要多语言支持,我只需要法语。

最佳答案

要使用本地化,您需要使用 Hugo 函数 time.Format(别名 dateFormat)。它有两个参数:

  • 所需格式
  • time.Time 对象,或时间戳

例子:

{{ time.Format "Jan. 2, 2006".Date }}

{{ dateFormat "Jan. 2, 2006".Date }}

文档:https://gohugo.io/functions/dateformat/

.Format 方法(例如 {{.Date.Format "Jan. 2, 2006}})不会应用所需的本地化。

关于date - 雨果,如何设置日期语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71387017/

相关文章:

algorithm - 找到最近的时间跨度

javascript - 在工作时间显示/隐藏 div,与 UTC 混合?

hugo - 为什么 Hugo 提供空白页?

google-app-engine - 将 Hugo 站点部署到 GAE 结果为 "internal error 13"

r - 基本目录中的index.Rmd 文件的用途是什么?

python - Pandas 拆解专栏

r - 按 R 中可用总数据的最后 12 个月过滤数据

php - 如何在php中转换这种日期格式?

javascript - 将登录页面集成到hugo

hugo - 如何从 Hugo 的公共(public)目录中排除图像?