gohugoio/hugo · error
invalid deployment.target.include
Error message
invalid deployment.target.include %q: %v
What it means
Target.ParseIncludeExclude (deploy/deployconfig/deployConfig.go:82) compiles the target's Include field via hglob.GetGlob. This wraps a glob-parse failure. The Include field restricts which files a deployment target uploads.
Solutions
- Validate the Include value as a glob; prefer simple patterns like '**/*.css'.
- Remember include/exclude are globs (hglob), not regex.
- Balance any brackets/braces in the pattern.
Example fix
# before [[deployment.targets]] name = "cdn" include = "[assets" # unclosed bracket # after [[deployment.targets]] name = "cdn" include = "assets/**"
Defensive patterns
Strategy: validation
Validate before calling
import "github.com/gohugoio/hugo/hugofs/hglob"
func ValidateIncludeGlob(pattern string) error {
if pattern == "" { return nil }
_, err := hglob.GetGlob(pattern)
return err
} Try / catch
if err := tgt.ParseIncludeExclude(); err != nil {
return err
} Prevention
- Treat include/exclude as globs, not regex.
- Lint include patterns in CI with hglob.GetGlob.
- Prefer simple '**/...' patterns.
When it happens
Trigger: Setting `include` on a [[deployment.targets]] entry to a value hglob cannot parse (e.g. an unmatched bracket or other glob syntax error).
Common situations: Confusing glob and regex syntax in include; a bracket expression like '[abc' that is unclosed.
Related errors
- invalid deployment.target.exclude
- deployment target not found
- empty deployment matcher
- empty deployment target
- failed to compile Headers glob
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/0c7753750ba8275c.
Report an issue: GitHub.
Appendix: 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 52c9bd7908)