-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Found while addressing #13199.
(allconfig.Configs).Init builds (allconfig.Configs).LanguageConfigSlice by appending one element per language in an indeterminate order. Then it appends to the slice again, one element per language sorted by language weight.
So this site configuration:
[languages.en]
title = 'TITLE_EN'
weight = 2
[languages.de]
title = 'TITLE_DE'
weight = 1
[languages.fr]
title = 'TITLE_FR'
weight = 3
...results in a slice with too many elements, ordered like this:
[en de fr de en fr]
--------
indeterminate order
We only want the last three so that (allconfig.Configs).LanguageConfigSlice[0] returns the config with the lowest weight.
I looked at our usage of this slice, and from a practical standpoint I think it only affects the output from the hugo config command, and even then only under certain conditions.
But we should fix this anyway.
https://github.com/gohugoio/hugo/blob/master/config/allconfig/allconfig.go#L750-L775