Error with item defined config file

I have DefaultLanguage = "en-GB" defined in config.toml and then this code in every header of every layout <html lang="{{ .Site.DefaultLanguage }}">. It was working well and then suddenly started triggering build errors until I moved DefaultLanguage = "en-GB" under [params]. What could be triggering this? I have had such cases also happen until I moved the codes under params. Error reads
Error: Error building site: failed to render pages: render of "page" failed: "C:\Users\dd\Documents\Hugo\Site\dd\layouts\_default\single.html:2:20": execute of template failed: template: _default/single.html:2:20: executing "_default/single.html" at <.Site.DefaultLanguage>: can't evaluate field DefaultLanguage in type page.Site

Show us the template that is calling {{ .Site.DefaultLanguage }}. Maybe you are “out of context” somehow. You can easily test that by using site.DefaultLanguage instead of the .Site version. site gives you global access to what the .Site would hand you locally.

You might have an issue with your language setup. Add your config for that too.

Sidenote: in my own templates I have this:

<html lang="{{- site.LanguageCode | default "en-US" -}}">

… and obviously use LanguageCode in my config.toml. Not 100% sure which one is the right one, but I would assume it’s me because “default language” implies multiple available languages and you don’t want to generally set the language for all your pages with the default one, instead using the “current” one.

With multiple languages the one for the HTML tag would be the current language of the current post.

.Site.DefaultLanguage isn’t a thing, and never has been.

So everything not listed there should be under [params]? Maybe that’s why` .Site.Description did not work either.

Custom site parameters must be defined under [params] in your site configuration.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.