gohugoio/hugo · error
empty deployment target
Error message
empty deployment target
What it means
In `deployconfig.DecodeConfig`, after weak-decoding the `deployment` section Hugo iterates the targets and rejects any that equal the zero-value `Target{}` — meaning a target entry exists in config but carries no name, URL, or any other field. An empty target is unusable (no destination to deploy to), so config decoding fails fast.
Source
Thrown at deploy/deployconfig/deployConfig.go:154
// DecodeConfig creates a config from a given Hugo configuration.
func DecodeConfig(cfg config.Provider) (DeployConfig, error) {
dcfg := DefaultConfig
if !cfg.IsSet(DeploymentConfigKey) {
return dcfg, nil
}
if err := mapstructure.WeakDecode(cfg.GetStringMap(DeploymentConfigKey), &dcfg); err != nil {
return dcfg, err
}
if dcfg.Workers <= 0 {
dcfg.Workers = 10
}
for _, tgt := range dcfg.Targets {
if *tgt == (Target{}) {
return dcfg, errors.New("empty deployment target")
}
if err := tgt.ParseIncludeExclude(); err != nil {
return dcfg, err
}
}
var err error
for _, m := range dcfg.Matchers {
if *m == (Matcher{}) {
return dcfg, errors.New("empty deployment matcher")
}
m.Re, err = regexp.Compile(m.Pattern)
if err != nil {
return dcfg, fmt.Errorf("invalid deployment.matchers.pattern: %v", err)
}
}
for _, o := range dcfg.Order {
re, err := regexp.Compile(o)
if err != nil {View on GitHub ↗ (pinned to 8a468df065)
Solutions
- Fill in the target: at minimum `name` and `url`, e.g. `name = "prod"` and `url = "gs://my-bucket"` under `[[deployment.targets]]`.
- Delete any leftover empty `[[deployment.targets]]` blocks from the config.
- Check YAML indentation so target keys are children of the list item; check field names against the Hugo deployment docs (name, url, cloudFrontDistributionID, googleCloudCDNOrigin, include, exclude, stripIndexHTML).
Example fix
# before [[deployment.targets]] # after [[deployment.targets]] name = "production" url = "gs://my-bucket"
Defensive patterns
Strategy: validation
Validate before calling
target := cfg.GetString("deployment.targets[0].name")
if strings.TrimSpace(target) == "" {
return errors.New("deployment target name must be non-empty")
} Prevention
- Give every `[[deployment.targets]]` entry a non-empty name and URL
- When passing `--target`, ensure the flag value is non-empty and matches a configured target
- Validate deployment config at startup rather than at deploy time
When it happens
Trigger: `hugo deploy` with a `[[deployment.targets]]` (TOML) / `deployment.targets: - ` (YAML) entry whose keys are all empty/absent or misspelled so that mapstructure decodes nothing into the struct.
Common situations: A stray empty `[[deployment.targets]]` table left in hugo.toml, YAML list item with wrong indentation so its keys don't nest under the target, or misspelled field names (e.g. `url =` vs `URL =` is fine, but `bucket =` decodes to nothing) leaving every field at zero value.
Related errors
- invalid deployment.target.include %q: %v
- invalid deployment.target.exclude %q: %v
- origin must be <project>/<origin>
- unknown dimension %q
- redirects must have either From or FromRe set
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/97d20684c24948b1.json.
Report an issue: GitHub ↗.