rhugoquartoblogdown

In a Hugo Apéro blog, how to change the global date format


In a newly created Hugo Apéro blog, all posts and elements in the site have their date in the following format: "November 1, 2024".

Is there a way to change all dates to a different format? My main problem is that dates are in english, so I would prefer having dates in spanish ("1 de noviembre, 2024"), or at least avoid words altogether ("01/11/2024").

Is there a global setting somewhere to change date formats in Hugo Apéro?

I've checked the documentation, and it says something about a template code, but it is not clear where I should change that setting i order to get localized dates.


Solution

  • It is possible to modify the Hugo theme directly in order to individual dates across your site. It seems there is not a single place to make a change that is global to the site.

    The files are located in: ~/R/blog/blog-r/themes/hugo-apero/layouts/

    To change date format in a Hugo Apero blog, you have to browse the theme files, and change all instances of {{ .PublishDate.Format "January 2, 2006" }} to your desired date format, considering that the day, month and year specified must be 02, January and 2006. So, if you want to change the date "November 7, 2024" into "7/11/2024", you need to change the previous code into {{ .PublishDate.Format "2/1/2006" }}, across all instances of dates in your site.