Skip to content
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

config/allconfig: Slice of language configs has double the expected elements #13201

Closed
jmooring opened this issue Dec 29, 2024 · 1 comment · Fixed by #13202
Closed

config/allconfig: Slice of language configs has double the expected elements #13201

jmooring opened this issue Dec 29, 2024 · 1 comment · Fixed by #13202
Assignees
Milestone

Comments

@jmooring
Copy link
Member

jmooring commented Dec 29, 2024

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

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants