diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-01-15 18:45:51 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-01-16 15:34:16 +0100 |
commit | f38a2fbd2e4de7f095a833b448cb8bc053955ce2 (patch) | |
tree | 3c88d0c12efa09ef3cc189a5859620b771004c7f /config | |
parent | 6a579ebac3a81df61f22988e3eb55f7cb35ce523 (diff) |
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
Diffstat (limited to 'config')
-rw-r--r-- | config/configLoader.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/config/configLoader.go b/config/configLoader.go index 6722c12fd..95594fc62 100644 --- a/config/configLoader.go +++ b/config/configLoader.go @@ -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) |