trying the latest Hugo release I feel a bit lost regarding the template system changes.
From the bug tracker issue mentioned in the release notes, I was under the impression that it should be sufficient to rename the /layouts/partials and /layouts/shortcodes directories to /layouts/_partials and /layouts/_shortcodes and adjust the partials path in my template partials accordingly.
But Hugo complains: ... readAndProcessContent: ".../index.md:126:1": failed to extract shortcode: template for shortcode "fr" not found.
The file /layouts/_shortcodes/fr.md exists. Is there more to update and I should wait until proper documentation is in place? Or could this be an error? Thanks.
In most cases, that is true. But there are some edge cases. We consolidated all of the “template lookups” to follow the same code path. That means we also fixed a bug or two. One of them is that we don’t consider plain text templates for shortcodes when rendering HTML. This is a security related bug fix.
To get passed this, you either need to
Rename the shortcode to e.g. `fr.html``
Redefine the markdown output format and set isPlainText = false.
My apologies. That was a typo. The shortcode file is already named: /layouts/_shortcodes/fr.html
But at least this confirms that I’m heading in the right direction. I did not find any other instructions regarding the upgrade and was unsure because of the issue.
I use some external modules that I haven’t updated yet. So I fully expect that the build fails. But the only error currently displayed is the issue with the shortcode which should not be related, because the shortcode is part of the project itself. But maybe it’s still a consequence of the currently broken setup. I will check that.
I will fix this in a release within a day or two. The only workaround I can think of is to rename the shortcode to something that isn’t also a defined language.
@bep Actually I didn’t have fr enabled. I forgot that in order to speed up rebuilding during development, the secondary languages were disabled in the development config:
same for me, I disabled de and the error occurs IF (default is en)
en/_index.md contains {{< de >}}
but not if
en/_index.md contains {{< en >}}
Error: error building site: process: readAndProcessContent: "C:\_repos\github\jmooring\hugo-forum-topic-48029-multilingual-single-host\content\de\_index.md:10:1": failed to extract shortcode: template for shortcode "en" not found
I’m nearly done upgrading and I’ve ran into another issue, you might want to streamline (or document): I’m using configuration by convention for Hugo modules and check for a specific template to perform setup.
The code first looks for the partial and then tries to load it:
Turns out the templates.Exists call requires the full path, but the partial call fails if the _partials/ path prefix is present. I would prefer the same policy for both functions.