gohugoio/hugo · error
failed to init mount
Error message
failed to init mount %q %d: %w
What it means
Thrown inside the loop that derives default mounts from the project's component directory settings (modules/config.go:162). For each language index i and component dir (contentDir, layoutDir, assetDir, etc.), Hugo builds a Mount and calls mnt.init(logger); failure is wrapped with the language code and the iteration index.
Solutions
- Review your per-language directory settings (contentDir, layoutDir, etc.) for consistency across language blocks.
- Align sites.matrix configuration with your language definitions and remove legacy mount.lang overrides.
- Simplify to a single language to isolate whether the issue is language-scoping specific.
Example fix
// before [languages.fr] contentDir = 'content/fr' # conflicting/missing matrix on a mount derived from these // after [languages.fr] contentDir = 'content/fr' weight = 2
Defensive patterns
Strategy: validation
Validate before calling
// validate per-language component dir settings are consistent
for _, lang := range cfg.Languages {
if lang.ContentDir == "" { continue }
if !dirExists(filepath.Join(workDir, lang.ContentDir)) {
return fmt.Errorf("language %s contentDir %q missing", lang.Lang, lang.ContentDir)
}
} Prevention
- Keep per-language dir settings uniform and existing.
- Avoid mixing legacy mount.lang with sites.matrix.
- Re-test multilingual configs after Hugo upgrades.
When it happens
Trigger: A default component-directory mount (auto-created from settings like contentDir/assetDir/i18nDir) fails Mount.init, typically because of an invalid sites.matrix/lang combination produced from per-language config.
Common situations: A multilingual setup where a per-language component dir setting conflicts with sites.matrix; upgrading Hugo versions that changed how default mounts carry language scope; malformed language configuration in languages.xx blocks.
Related errors
- failed to compile permalink target
- failed to decode sites from front matter
- cannot use --renderToMemory with --destination
- cardinalityThreshold threshold must be between 0 and 100
- failed to compile cascade target
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/af7ec310de375eb4.
Report an issue: GitHub.
Appendix: source
Thrown at modules/config.go:162
Matrix: sitesmatrix.StringSlices{
Languages: []string{l.Lang},
},
}
}
// Static mounts are a little special.
if component == files.ComponentFolderStatic {
staticDirs := cfg.StaticDirs()
for _, dir := range staticDirs {
mounts = append(mounts, Mount{Sites: sites, Source: dir, Target: component})
}
continue
}
if dir != "" {
mnt := Mount{Source: dir, Target: component, Sites: sites}
if err := mnt.init(logger); err != nil {
return fmt.Errorf("failed to init mount %q %d: %w", lang, i, err)
}
mounts = append(mounts, mnt)
}
}
}
moda.mounts = append(moda.mounts, mounts...)
moda.mounts = filterDuplicateMounts(moda.mounts)
return nil
}
// DecodeConfig creates a modules Config from a given Hugo configuration.
func DecodeConfig(logger logg.Logger, cfg config.Provider) (Config, error) {
return decodeConfig(logger, cfg, nil)
}
View on GitHub (pinned to 52c9bd7908)