gohugoio/hugo · error
failed to compile ignoreFiles pattern
Error message
failed to compile ignoreFiles pattern %q: %s
What it means
Returned by CompileConfig when compiling the `ignoreFiles` regex patterns fails. Each pattern is compiled with regexp.Compile; a syntax error in any pattern aborts config compilation and names the offending pattern plus the regexp error.
Solutions
- Test each pattern with a Go regexp playground or `go run -` using regexp.Compile.
- Use RE2-compatible syntax; remove look-ahead/look-behind and backreferences.
- Double-escape backslashes in TOML (`\\.` not `\.`) and verify in YAML/JSON accordingly.
- Remove patterns one by one to isolate the bad one.
Example fix
// before
ignoreFiles = ["\\.draft("]
// after
ignoreFiles = ["\\.draft$"] Defensive patterns
Strategy: validation
Validate before calling
func compileIgnoreFiles(patterns []string) error {
for _, p := range patterns { if _, err := regexp.Compile(p); err != nil { return fmt.Errorf("bad ignoreFiles pattern %q: %w", p, err) } }
return nil
} Prevention
- Test each ignoreFiles pattern with regexp.Compile before committing.
- Prefer RE2 syntax; avoid look-around and backreferences.
- Mind TOML backslash escaping (use "\\.").
When it happens
Trigger: Setting `ignoreFiles = ["\\.foo(", "[a-"]"]` or any PCRE/Go-re2 syntax error: unbalanced parentheses, malformed character classes, unsupported look-ahead (re2 has none), or stray backslashes.
Common situations: Porting ignore patterns from JavaScript/PCRE regex dialects into Hugo (which uses Go's RE2 engine), unescaped backslashes in TOML strings, or trailing partial patterns from manual edits.
Related errors
- failed to compile cache buster target
- failed to compile whitelist pattern
- failed to parse clock
- failed to parse timeout
- invalid deployment.matchers.pattern
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/66e7e0753acad34d.
Report an issue: GitHub.
Appendix: source
Thrown at config/allconfig/allconfig.go:375
case bool:
return v
case map[string]bool:
return v[section]
default:
return false
}
}
ignoreFile := func(s string) bool {
return false
}
if len(c.IgnoreFiles) > 0 {
regexps := make([]*regexp.Regexp, len(c.IgnoreFiles))
for i, pattern := range c.IgnoreFiles {
var err error
regexps[i], err = regexp.Compile(pattern)
if err != nil {
return fmt.Errorf("failed to compile ignoreFiles pattern %q: %s", pattern, err)
}
}
ignoreFile = func(s string) bool {
for _, r := range regexps {
if r.MatchString(s) {
return true
}
}
return false
}
}
var clock time.Time
if c.Internal.Clock != "" {
var err error
clock, err = time.Parse(time.RFC3339, c.Internal.Clock)
if err != nil {
return fmt.Errorf("failed to parse clock: %s", err)View on GitHub (pinned to 52c9bd7908)