gohugoio/hugo · error
deployment target %q not found
Error message
deployment target %q not found
What it means
Raised in deploy.New (deploy/deploy.go:98) when a target name was requested (via `hugo deploy --target <name>` or `deployment.target` in config) but no entry in `deployment.targets` has a matching `name`. Matching is exact and case-sensitive; without a name Hugo defaults to the first target, so this only fires when a name was explicitly given.
Source
Thrown at deploy/deploy.go:98
if len(dcfg.Targets) == 0 {
return nil, errors.New("no deployment targets found")
}
mediaTypes := cfg.GetConfigSection("mediaTypes").(media.Types)
// Find the target to deploy to.
var tgt *deployconfig.Target
if targetName == "" {
// Default to the first target.
tgt = dcfg.Targets[0]
} else {
for _, t := range dcfg.Targets {
if t.Name == targetName {
tgt = t
}
}
if tgt == nil {
return nil, fmt.Errorf("deployment target %q not found", targetName)
}
}
return &Deployer{
localFs: localFs,
target: tgt,
quiet: cfg.BuildExpired(),
mediaTypes: mediaTypes,
cfg: dcfg,
}, nil
}
func (d *Deployer) openBucket(ctx context.Context) (*blob.Bucket, error) {
if d.bucket != nil {
return d.bucket, nil
}
d.logger.Printf("Deploying to target %q (%s)\n", d.target.Name, d.target.URL)
return blob.OpenBucket(ctx, d.target.URL)View on GitHub ↗ (pinned to 8a468df065)
Solutions
- List the configured targets (check `[[deployment.targets]]` blocks or `hugo config`) and pass one of their exact `name` values to `--target`.
- Fix the case/spelling mismatch — comparison is exact.
- If the target lives in an environment-specific config, add `--environment <env>` so that config is loaded.
- Omit `--target` to deploy to the first configured target.
Example fix
# before hugo deploy --target Production # config has name = "production" # after hugo deploy --target production
Defensive patterns
Strategy: validation
Validate before calling
names := map[string]bool{}
for _, t := range cfg.Deployment.Targets {
names[t.Name] = true
}
if !names[flagTarget] {
return fmt.Errorf("unknown deploy target %q; available: %v", flagTarget, maps.Keys(names))
} Prevention
- Pass `--target` values that exactly match a target's `name` field (it's case-sensitive)
- Centralize target names as constants/env vars in deploy scripts instead of retyping them
- List configured targets in CI logs before deploying so mismatches are obvious
When it happens
Trigger: `hugo deploy --target staging` where no `[[deployment.targets]]` block has `name = "staging"`; or `deployment.target` set in config to a name that doesn't exist in the targets list.
Common situations: Typos or case mismatches between the CLI flag and the config `name`; renaming a target in config without updating CI scripts; the intended target defined only in another environment's config file.
Related errors
- language %q not found
- unsupported format: %q
- deploy not supported in this version of Hugo; install a rele
- Unable to locate config file or config directory. Perhaps yo
- ErrNoConfigFile
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/827cb9e05e7cb88f.json.
Report an issue: GitHub ↗.