-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
different behavior on the same config file but with different format #8427
Comments
Hugo is doing the right thing when it raises an error while unmarshaling this TOML data. The TOML spec does not allow duplicate keys. Hugo should (theoretically) raise an error while unmarshaling this YAML data, because the YAML spec does not allow duplicate keys either. I think we are currently calling Unmarshal instead of UnmarshalStrict.
Currently, with identical YAML keys, the later declaration overrides the earlier declaration. I have no idea if anyone relies on this behavior. There's a chance that switching to UnmarshalStrict would break things, but I suspect this is a low probability. |
I think I stumbled over this issue when I tried to upgrade to v3 of the Yaml library (which I think is strict with no option to turn it off) -- and I suspect that this was the reason I put that on ice. And I think we need to do it as part of that upgrade ... This is a think we really should do, but it will create a lot of noise/questions both here and on the forum. |
v3 unmarshal docs state:
And there is not an "unstrict" option. So at some point there's going to be some pain. |
The only way to ease that transition is to unmarshal twice: once in normal mode and a second in strict mode to log warnings. We can control this in yaml/v3 with |
Or the other way around:
|
Revisit this once #8822 is complete. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes
How to reproduce
Create new empty site
Create a new yaml config with this content:
opengraph:
twitter:
defaultImage:
opengraph:
launch hugo server - all is ok
Create a toml config with the same content but in toml format:
[opengraph]
[twitter]
[defaultImage]
[opengraph]
launching hugo server rise this error:
Error: "/home/xxxxx/hugo_extended_0.82.0/try/config.toml:6:1": unmarshal failed: Near line 6 (last key parsed ''): Key 'opengraph' has already been defined.
The text was updated successfully, but these errors were encountered: