Make hugo.toml the new config.toml

Both will of course work, but hugo.toml will win if both are set.

We should have done this a long time ago, of course, but the reason I'm picking this up now is that my VS Code setup by default picks up some
JSON config schema from some random other software which also names its config files config.toml.

Fixes #8979
This commit is contained in:
Bjørn Erik Pedersen
2023-01-15 18:45:51 +01:00
parent 6a579ebac3
commit f38a2fbd2e
7 changed files with 111 additions and 24 deletions

View File

@@ -29,11 +29,22 @@ import (
)
var (
// See issue #8979 for context.
// Hugo has always used config.toml etc. as the default config file name.
// But hugo.toml is a more descriptive name, but we need to check for both.
DefaultConfigNames = []string{"hugo", "config"}
DefaultConfigNamesSet = make(map[string]bool)
ValidConfigFileExtensions = []string{"toml", "yaml", "yml", "json"}
validConfigFileExtensionsMap map[string]bool = make(map[string]bool)
)
func init() {
for _, name := range DefaultConfigNames {
DefaultConfigNamesSet[name] = true
}
for _, ext := range ValidConfigFileExtensions {
validConfigFileExtensionsMap[ext] = true
}
@@ -142,8 +153,7 @@ func LoadConfigFromDir(sourceFs afero.Fs, configDir, environment string) (Provid
}
var keyPath []string
if name != "config" {
if !DefaultConfigNamesSet[name] {
// Can be params.jp, menus.en etc.
name, lang := paths.FileAndExtNoDelimiter(name)