Why `replace` works for hugo's config file and not 'dict'?

After recently discovering how to use custom variables in i18n, I was wondering why the same does not work in the config file, but replace does, albeit for variables with single curly brackets like {year}.

Im not sure I follow the last part, but for the first, I assume you mean that it’s not possible to use Go template syntax in config files. e.g hugo.toml, e.g:

baseURL = "{{ site.BaseURL }}"

The short answer, the above is not a TOML thing, and we haven’t implemented “string template expansion” as a generat thing in Hugo. I have deliberately made the above example a little stupid (there’s a chicken and egg situation).

But we have considered adding


Understood. My usage example is something like copyright = "2015-{year} that I saw somewhere in this forum in the past. Then replace works here replacing {year} with now.Format "2006". But doing something like {{ .Year }} and using dict instead returns an error instead (something about site.Copyright having 1 argument while it expects 0).

OK, what you talk about have some use cases, but in most situations I suspect you will be better off by having the presentation logic in the templates.

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