{"id":"66e7e0753acad34d","repo":"gohugoio/hugo","slug":"failed-to-compile-ignorefiles-pattern-q-s","errorCode":null,"errorMessage":"failed to compile ignoreFiles pattern %q: %s","messagePattern":"failed to compile ignoreFiles pattern %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/allconfig.go","lineNumber":375,"sourceCode":"\t\tcase bool:\n\t\t\treturn v\n\t\tcase map[string]bool:\n\t\t\treturn v[section]\n\t\tdefault:\n\t\t\treturn false\n\t\t}\n\t}\n\n\tignoreFile := func(s string) bool {\n\t\treturn false\n\t}\n\tif len(c.IgnoreFiles) > 0 {\n\t\tregexps := make([]*regexp.Regexp, len(c.IgnoreFiles))\n\t\tfor i, pattern := range c.IgnoreFiles {\n\t\t\tvar err error\n\t\t\tregexps[i], err = regexp.Compile(pattern)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to compile ignoreFiles pattern %q: %s\", pattern, err)\n\t\t\t}\n\t\t}\n\t\tignoreFile = func(s string) bool {\n\t\t\tfor _, r := range regexps {\n\t\t\t\tif r.MatchString(s) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t}\n\n\tvar clock time.Time\n\tif c.Internal.Clock != \"\" {\n\t\tvar err error\n\t\tclock, err = time.Parse(time.RFC3339, c.Internal.Clock)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse clock: %s\", err)","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/config/allconfig/allconfig.go#L357-L393","documentation":"`ignoreFiles` entries are compiled as Go (RE2) regular expressions used to skip content/asset files. If `regexp.Compile` rejects a pattern, config compilation fails with this error, naming the bad pattern and the regexp error.","triggerScenarios":"An `ignoreFiles` entry with invalid RE2 syntax — unbalanced parentheses/brackets, or PCRE-only constructs like lookaheads `(?!...)` or backreferences `\\1`, which Go's regexp does not support.","commonSituations":"Users writing glob patterns (`*.tmp`) that happen to be invalid regexes or match unintended files, copying PCRE patterns from other tools, or unescaped special characters in file paths (e.g. `.` or `(` in directory names).","solutions":["Fix the regex syntax; remember these are RE2 regular expressions, not globs — use `\\\\.tmp$` not `*.tmp`.","Remove PCRE-only constructs (lookaround, backreferences); restructure the pattern with alternation instead.","Escape literal special characters in paths: `content/\\\\(drafts\\\\)/`.","Test the pattern quickly with `go doc regexp/syntax` rules or an RE2-compatible tester."],"exampleFix":"# before\nignoreFiles = [\"*.tmp\", \"(?!keep).*\\\\.bak\"]\n# after\nignoreFiles = [\"\\\\.tmp$\", \"\\\\.bak$\"]","handlingStrategy":"validation","validationCode":"for _, pat := range ignoreFiles {\n    if _, err := regexp.Compile(pat); err != nil {\n        return fmt.Errorf(\"ignoreFiles pattern %q: %w\", pat, err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember ignoreFiles entries are regular expressions, not globs — escape dots and don't use \"*.md\"","Test each pattern with regexp.Compile (patterns are matched case-insensitively) before shipping config","Prefer simple anchored patterns like \"\\\\.foo$\""],"tags":["hugo","config","regex","ignore-files"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}