TOML dotted key seems not supported in data files

Hello Hugo,

I got this error when I put a dotted key in a TOML data file.

When I put a dotted key in config.toml, hugo does not seem to complain. I’m on termux android with latest hugo termux package. This hugo release has go-toml 1.6 I think and dotted keys were already implemented in that one from the info I found on the git repo.

Any idea on what could have go wrong ??

Cheers,
Olivier

Dotted keys were added to the TOML spec on Jul 10, 2018. See https://github.com/toml-lang/toml/releases/tag/v0.5.0.

The TOML parser we use does not yet support dotted keys:

An issue was created in the Hugo issue queue this morning, proposing deprecation of https://github.com/BurntSushi/toml in favor of https://github.com/pelletier/go-toml.

As a workaround, you can quote-encapsulate the dotted keys:

data/foo.toml

[fruit]
[fruit.orange]
"physical.color" = "orange"
"physical.shape" = "round"
[fruit.banana]
"physical.color" = "yellow"
"physical.shape" = "oblong"

template

{{ index .Site.Data.foo.fruit.orange "physical.color" }}
{{ index .Site.Data.foo.fruit.orange "physical.shape" }}
1 Like

I just grepped go.mod for toml:

github.com/BurntSushi/toml v0.3.1
github.com/pelletier/go-toml v1.6.0 // indirect

I am not sure what “indirect” means, nor how these two modules are invoked/interact.

Indirect means that we import a package that uses go-toml, but we don’t directly import it.