Hello,
I decided to add another language to my site, but I have trouble understanding how to configure a multilingual site in Hugo. I read Multilingual mode and Configure languages sections of the documentation and would like to use translation by file name instead of translation by content directory, because I prefer to have all language versions for each content item to reside in the same directory, as it feels more manageable.
So, I added a [languages] section to my config.toml file featuring two languages, and I chose the default content language along with the type of translation management:
# (...)
[languages]
[languages.en]
disabled = false
languageCode = 'en-US'
languageName = 'EN'
title = 'Test EN'
weight = 1
[languages.pl]
disabled = false
languageCode = 'pl-PL'
languageName = 'PL'
title = 'Test PL'
weight = 2
defaultContentLanguage = "en"
defaultContentLanguageInSubdir = true # Doesn't matter if it's on or off
# (...)
However, if I try to preview or build the site, I immediately get an error regarding shortcodes:
Error: error building site: process: readAndProcessContent: "/path_to_hugo_site/content/some_content/_index.md:8:28": failed to extract shortcode: template for shortcode "shortcode_name" not found
shortcode_name.html, as well as other shortcodes, reside in my theme’s layouts/shortcodes/ directory and they were processed without problems before I added the language specific configuration options that I listed above.
At first, I thought that perhaps I should add a language code to each shortcode, like shortcode_name.en.html and shortcode_name.pl.html, for example, but it didn’t affect the error. Not surprising, because the documentation states that:
If a file has no language code, it will be assigned the default language.
So I assume that if a language code is not found in any of the files, a file without the code will be used. The culprit must lie somewhere else.
Anyway, I’m wondering what am I missing here? Why does Hugo complain about the missing shortcode files? Any advice is welcome.