Skip to content

defaultContentLanguage must be set if no English lang is defined #13646

@bep

Description

@bep

Which is a little inconvenient ...

This fails with:

func TestDefaaultConfigLanguageBlankWhenNoEnglishExists(t *testing.T) {
	t.Parallel()

	files := `
-- hugo.toml --
baseURL = "https://example.com"
[languages]
[languages.nn]
weight = 20
[languages.sv]
weight = 10
-- layouts/all.html --
All.
`

	b := hugolib.Test(t, files)

	b.Assert(b.H.Conf.DefaultContentLanguage(), qt.Equals, "sv")
}
failed to decode "languages": config value "en" for defaultContentLanguage does not match any language definition`

We should be smarter here and pick the first (sv) language.

Edit in: Looking at some failing tests, I would say that to avoid breakage we need to:

  • If en is one of the languages, we pick that as the default.
  • Else the first language.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions