Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share front matter between translations

Tags:

hugo

I have a Hugo site with translations per file, using page bundles.

So the About page looks like this:

- about
  - about-image.jpg
  - index.en.md
  - index.nl.md
  - index.fr.md

The problem is that I have to repeat the non-i18n front matter in all of the .md files.

For example, date, tags, et cetera.

Is there a way in hugo to define the (basic) front matter once, and have translations only contain overrides needed for i18n?

like image 956
dyve Avatar asked Oct 26 '25 11:10

dyve


1 Answers

You can define the default language in the config file of the site. Then, you set the strings that do not need to be translated only into the translation file of the default language, and you do not define them in the other files.

As the translations are missing, Hugo will default to the default language (if defined in the config file).

like image 178
Jeremie Avatar answered Oct 29 '25 05:10

Jeremie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!