code: func GetCacheDir(fs afero.Fs, cfg config.Provider) (string, error) {
  	cacheDir := getCacheDir(cfg)
  	if cacheDir != "" {
  		exists, err := DirExists(cacheDir, fs)
  		if err != nil {
  			return "", err
  		}
  		if !exists {
  			err := fs.MkdirAll(cacheDir, 0777) // Before umask
  			if err != nil {
  				return "", _errors.Wrap(err, "failed to create cache dir")
  			}
  		}
  		return cacheDir, nil
  	}
  
  	// Fall back to a cache in /tmp.
  	return GetTempDir("hugo_cache", fs), nil
  
  }
docs: // GetCacheDir returns a cache dir from the given filesystem and config.
  // The dir will be created if it does not exist.