Skip to content

Commit

Permalink
Search current directory for config file by default
Browse files Browse the repository at this point in the history
As of 2015-08-16, Viper no longer searches the CWD
for config file by default to avoid unintended surprises,
but Hugo relies on the original behaviour.

Fixed by calling

    viper.AddConfigPath(".")

at the appropriate place.

See spf13/viper#73 for more information.

Fixes gohugoio#1363
  • Loading branch information
anthonyfok authored and tychoish committed Aug 13, 2017
1 parent 9c52e65 commit 34dbaf3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion commands/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ func LoadDefaultSettings() {
// InitializeConfig initializes a config file with sensible default configuration flags.
func InitializeConfig() {
viper.SetConfigFile(CfgFile)
viper.AddConfigPath(Source)
// See https://github.com/spf13/viper/issues/73#issuecomment-126970794
if Source == "" {
viper.AddConfigPath(".")
} else {
viper.AddConfigPath(Source)
}
err := viper.ReadInConfig()
if err != nil {
jww.ERROR.Println("Unable to locate Config file. Perhaps you need to create a new site. Run `hugo help new` for details")
Expand Down

0 comments on commit 34dbaf3

Please sign in to comment.