code: func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provider) error) (*viper.Viper, []string, error) {
  	if d.Environment == "" {
  		d.Environment = hugo.EnvironmentProduction
  	}
  
  	var configFiles []string
  
  	v := viper.New()
  	l := configLoader{ConfigSourceDescriptor: d}
  
  	v.AutomaticEnv()
  	v.SetEnvPrefix("hugo")
  
  	var cerr error
  
  	for _, name := range d.configFilenames() {
  		var filename string
  		if filename, cerr = l.loadConfig(name, v); cerr != nil && cerr != ErrNoConfigFile {
  			return nil, nil, cerr
  		}
  		configFiles = append(configFiles, filename)
  	}
  
  	if d.AbsConfigDir != "" {
  		dirnames, err := l.loadConfigFromConfigDir(v)
  		if err == nil {
  			configFiles = append(configFiles, dirnames...)
  		}
  		cerr = err
  	}
  
  	if err := loadDefaultSettingsFor(v); err != nil {
  		return v, configFiles, err
  	}
  
  	if cerr == nil {
  		themeConfigFiles, err := l.loadThemeConfig(v)
  		if err != nil {
  			return v, configFiles, err
  		}
  
  		if len(themeConfigFiles) > 0 {
  			configFiles = append(configFiles, themeConfigFiles...)
  		}
  	}
  
  	// We create languages based on the settings, so we need to make sure that
  	// all configuration is loaded/set before doing that.
  	for _, d := range doWithConfig {
  		if err := d(v); err != nil {
  			return v, configFiles, err
  		}
  	}
  
  	if err := loadLanguageSettings(v, nil); err != nil {
  		return v, configFiles, err
  	}
  
  	return v, configFiles, cerr
  
  }
docs: // LoadConfig loads Hugo configuration into a new Viper and then adds
  // a set of defaults.