gohugoio/hugo · error
must be all lower case and no spaces
Error message
must be all lower case and no spaces
What it means
Returned by paths.ValidateIdentifier when the input string differs from paths.NormalizePathStringBasic(s), which lowercases the string and replaces spaces with hyphens. An identifier is valid only if it is already lowercase and space-free.
Solutions
- Lowercase the string and replace spaces with hyphens before validating.
- Reject mixed-case input at the UI/config layer.
- Use paths.NormalizePathStringBasic to canonicalize then store the result.
Example fix
// before
paths.ValidateIdentifier("My Section")
// after
s := strings.ToLower(strings.ReplaceAll("My Section", " ", "-"))
paths.ValidateIdentifier(s) Defensive patterns
Strategy: validation
Validate before calling
func normalized(s string) string { return strings.ToLower(strings.ReplaceAll(s, " ", "-")) }
func validIdent(s string) bool { return s == normalized(s) } Type guard
func isValidIdentifier(s string) bool { return s == paths.NormalizePathStringBasic(s) } Prevention
- Normalize identifiers before persisting them in config.
- Reject mixed-case input at the form/CLI layer.
- Add a config lint that runs ValidateIdentifier on all keys.
When it happens
Trigger: Calling paths.ValidateIdentifier(s) where s contains uppercase letters, spaces, or any character altered by ToLower / space-to-hyphen normalization.
Common situations: Custom Hugo modules or integration code validating user-supplied identifiers (language codes, taxonomy names, section keys) that came from config containing mixed case or spaces.
Related errors
- empty path is reserved for the home page
- id must not contain forward slashes
- alias "" is an empty string
- aligny must be one of top, center, bottom
- assemble
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/a2a649c016fc347d.
Report an issue: GitHub.
Appendix: source
Thrown at common/paths/pathparser.go:1092
func HasExt(p string) bool {
for i := len(p) - 1; i >= 0; i-- {
if p[i] == '.' {
return true
}
if p[i] == '/' {
return false
}
}
return false
}
// ValidateIdentifier returns true if the given string is a valid identifier according
// to Hugo's basic path normalization rules.
func ValidateIdentifier(s string) error {
if s == NormalizePathStringBasic(s) {
return nil
}
return fmt.Errorf("must be all lower case and no spaces")
}
View on GitHub (pinned to 52c9bd7908)