@@ -19,6 +19,8 @@ import (
1919 "github.com/gohugoio/hugo/helpers"
2020 "github.com/spf13/afero"
2121 "github.com/spf13/viper"
22+ "io"
23+ "strings"
2224)
2325
2426// LoadConfig loads Hugo configuration into a new Viper and then adds
@@ -29,10 +31,10 @@ func LoadConfig(fs afero.Fs, relativeSourcePath, configFilename string) (*viper.
2931 if relativeSourcePath == "" {
3032 relativeSourcePath = "."
3133 }
32-
34+ configFilenames := strings . Split ( configFilename , "," )
3335 v .AutomaticEnv ()
3436 v .SetEnvPrefix ("hugo" )
35- v .SetConfigFile (configFilename )
37+ v .SetConfigFile (configFilenames [ 0 ] )
3638 // See https://github.com/spf13/viper/issues/73#issuecomment-126970794
3739 if relativeSourcePath == "" {
3840 v .AddConfigPath ("." )
@@ -46,6 +48,16 @@ func LoadConfig(fs afero.Fs, relativeSourcePath, configFilename string) (*viper.
4648 }
4749 return nil , fmt .Errorf ("Unable to locate Config file. Perhaps you need to create a new site.\n Run `hugo help new` for details. (%s)\n " , err )
4850 }
51+ for _ , configFile := range configFilenames [1 :] {
52+ var r io.Reader
53+ var err error
54+ if r , err = fs .Open (configFile ); err != nil {
55+ return nil , fmt .Errorf ("Unable to open Config file.\n (%s)\n " , err )
56+ }
57+ if err = v .MergeConfig (r ); err != nil {
58+ return nil , fmt .Errorf ("Unable to parse/merge Config file (%s).\n (%s)\n " , configFile , err )
59+ }
60+ }
4961
5062 v .RegisterAlias ("indexes" , "taxonomies" )
5163
0 commit comments