gohugoio/hugo · error
invalid deployment.target.include %q: %v
Error message
invalid deployment.target.include %q: %v
What it means
During `hugo deploy` config decoding, each target's `include` pattern is compiled via `hglob.GetGlob` (github.com/gobwas/glob) in `Target.ParseIncludeExclude`; if compilation fails, the pattern string and the underlying glob error are wrapped into this error. Hugo validates globs up front so a bad pattern aborts before any files are uploaded.
Source
Thrown at deploy/deployconfig/deployConfig.go:84
Include string
Exclude string
// Parsed versions of Include/Exclude.
IncludeGlob glob.Glob `json:"-"`
ExcludeGlob glob.Glob `json:"-"`
// If true, any local path matching <dir>/index.html will be mapped to the
// remote path <dir>/. This does not affect the top-level index.html file,
// since that would result in an empty path.
StripIndexHTML bool
}
func (tgt *Target) ParseIncludeExclude() error {
var err error
if tgt.Include != "" {
tgt.IncludeGlob, err = hglob.GetGlob(tgt.Include)
if err != nil {
return fmt.Errorf("invalid deployment.target.include %q: %v", tgt.Include, err)
}
}
if tgt.Exclude != "" {
tgt.ExcludeGlob, err = hglob.GetGlob(tgt.Exclude)
if err != nil {
return fmt.Errorf("invalid deployment.target.exclude %q: %v", tgt.Exclude, err)
}
}
return nil
}
// Matcher represents configuration to be applied to files whose paths match
// a specified pattern.
type Matcher struct {
// Pattern is the string pattern to match against paths.
// Matching is done against paths converted to use / as the path separator.
Pattern string
View on GitHub ↗ (pinned to 8a468df065)
Solutions
- Fix the glob syntax in the target's `include` setting — balance `{}`/`[]` groups, e.g. `"**.{html,css}"`.
- Use glob syntax (`*`, `**`, `{a,b}`, `[abc]`), not regex — gobwas/glob is the matcher.
- Test the pattern quickly with a small Go snippet or by re-running `hugo deploy --dryRun` after each fix.
Example fix
# before
[[deployment.targets]]
include = "**.{html,css"
# after
[[deployment.targets]]
include = "**.{html,css}" Defensive patterns
Strategy: validation
Validate before calling
if _, err := glob.Compile(includePattern); err != nil {
return fmt.Errorf("bad deployment.target.include %q: %w", includePattern, err)
} Prevention
- Test include patterns with a glob library (gobwas/glob syntax) before committing config
- Prefer simple patterns like `**.html` over complex nested braces
- Run `hugo deploy --dryRun` after editing target patterns
When it happens
Trigger: `hugo deploy` (or any DecodeConfig of the `deployment` section) with a target whose `include` value is an invalid gobwas/glob pattern — e.g. unbalanced `[` or `{`, like `include = "**.{html,css"`.
Common situations: Using regex syntax instead of glob syntax in the deployment config, unclosed brace/bracket groups, or copying gitignore-style patterns that aren't valid gobwas globs.
Related errors
- invalid deployment.target.exclude %q: %v
- empty deployment target
- origin must be <project>/<origin>
- unknown dimension %q
- failed to compile Headers glob %q: %w
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/0c7753750ba8275c.json.
Report an issue: GitHub ↗.