{"record":{"id":"a2a649c016fc347d","repo":"gohugoio/hugo","slug":"must-be-all-lower-case-and-no-spaces","errorCode":null,"errorMessage":"must be all lower case and no spaces","messagePattern":"must be all lower case and no spaces","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/paths/pathparser.go","lineNumber":1092,"sourceCode":"func HasExt(p string) bool {\n\tfor i := len(p) - 1; i >= 0; i-- {\n\t\tif p[i] == '.' {\n\t\t\treturn true\n\t\t}\n\t\tif p[i] == '/' {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn false\n}\n\n// ValidateIdentifier returns true if the given string is a valid identifier according\n// to Hugo's basic path normalization rules.\nfunc ValidateIdentifier(s string) error {\n\tif s == NormalizePathStringBasic(s) {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"must be all lower case and no spaces\")\n}\n","sourceCodeStart":1074,"sourceCodeEnd":1094,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/common/paths/pathparser.go#L1074-L1094","documentation":"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.","triggerScenarios":"Calling paths.ValidateIdentifier(s) where s contains uppercase letters, spaces, or any character altered by ToLower / space-to-hyphen normalization.","commonSituations":"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.","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."],"exampleFix":"// before\npaths.ValidateIdentifier(\"My Section\")\n// after\ns := strings.ToLower(strings.ReplaceAll(\"My Section\", \" \", \"-\"))\npaths.ValidateIdentifier(s)","handlingStrategy":"validation","validationCode":"func normalized(s string) string { return strings.ToLower(strings.ReplaceAll(s, \" \", \"-\")) }\n\nfunc validIdent(s string) bool { return s == normalized(s) }","typeGuard":"func isValidIdentifier(s string) bool { return s == paths.NormalizePathStringBasic(s) }","tryCatchPattern":null,"preventionTips":["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."],"tags":["paths","identifier","validation","lowercase"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}