{"id":"83808f415e07bab2","repo":"gohugoio/hugo","slug":"empty-deployment-matcher","errorCode":null,"errorMessage":"empty deployment matcher","messagePattern":"empty deployment matcher","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deploy/deployconfig/deployConfig.go","lineNumber":163,"sourceCode":"\t\treturn dcfg, err\n\t}\n\n\tif dcfg.Workers <= 0 {\n\t\tdcfg.Workers = 10\n\t}\n\n\tfor _, tgt := range dcfg.Targets {\n\t\tif *tgt == (Target{}) {\n\t\t\treturn dcfg, errors.New(\"empty deployment target\")\n\t\t}\n\t\tif err := tgt.ParseIncludeExclude(); err != nil {\n\t\t\treturn dcfg, err\n\t\t}\n\t}\n\tvar err error\n\tfor _, m := range dcfg.Matchers {\n\t\tif *m == (Matcher{}) {\n\t\t\treturn dcfg, errors.New(\"empty deployment matcher\")\n\t\t}\n\t\tm.Re, err = regexp.Compile(m.Pattern)\n\t\tif err != nil {\n\t\t\treturn dcfg, fmt.Errorf(\"invalid deployment.matchers.pattern: %v\", err)\n\t\t}\n\t}\n\tfor _, o := range dcfg.Order {\n\t\tre, err := regexp.Compile(o)\n\t\tif err != nil {\n\t\t\treturn dcfg, fmt.Errorf(\"invalid deployment.orderings.pattern: %v\", err)\n\t\t}\n\t\tdcfg.Ordering = append(dcfg.Ordering, re)\n\t}\n\n\treturn dcfg, nil\n}\n","sourceCodeStart":145,"sourceCodeEnd":180,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/deploy/deployconfig/deployConfig.go#L145-L180","documentation":"Raised in DecodeConfig (deploy/deployconfig/deployConfig.go:163) while decoding the `[deployment]` section of Hugo's config. Each entry in `deployment.matchers` is checked against the zero-value Matcher struct; if none of its fields (pattern, cacheControl, contentEncoding, contentType, gzip, force) are set, Hugo refuses the config because an empty matcher would match nothing and indicates a typo or malformed TOML/YAML block.","triggerScenarios":"Running `hugo deploy` (or any command that decodes site config with a deployment section) where a `[[deployment.matchers]]` table exists but contains no recognized keys, e.g. an empty `[[deployment.matchers]]` block or keys misspelled/mis-nested so mapstructure decodes them into nothing.","commonSituations":"Leaving a stub `[[deployment.matchers]]` block after deleting its contents; indenting matcher keys wrongly in YAML so they attach to the wrong level; typos like `patern` that leave the struct empty; copy-pasting docs examples partially.","solutions":["Remove the empty `[[deployment.matchers]]` block from your config, or add at least `pattern = \"...\"` to it.","Check for misspelled/mis-indented keys under deployment.matchers — every key must decode into a Matcher field (pattern, cacheControl, contentEncoding, contentType, gzip, force).","Validate the config structure with `hugo config | grep -A10 deployment` to see what actually decoded."],"exampleFix":"# before\n[[deployment.matchers]]\n\n# after\n[[deployment.matchers]]\npattern = \"^.+\\\\.(js|css|svg|ttf)$\"\ncacheControl = \"max-age=31536000, no-transform, public\"\ngzip = true","handlingStrategy":"validation","validationCode":"for i, m := range cfg.Deployment.Matchers {\n    if m.Pattern == \"\" {\n        return fmt.Errorf(\"deployment.matchers[%d]: pattern must be non-empty\", i)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never emit an empty [[deployment.matchers]] table in hugo.toml; every matcher needs a pattern key","Lint your deployment config in CI with `hugo deploy --dryRun` before real deploys","When generating config programmatically, skip matcher entries whose pattern is blank instead of writing them"],"tags":["hugo","deploy","config-validation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}