{"id":"827cb9e05e7cb88f","repo":"gohugoio/hugo","slug":"deployment-target-q-not-found","errorCode":null,"errorMessage":"deployment target %q not found","messagePattern":"deployment target %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deploy/deploy.go","lineNumber":98,"sourceCode":"\n\tif len(dcfg.Targets) == 0 {\n\t\treturn nil, errors.New(\"no deployment targets found\")\n\t}\n\tmediaTypes := cfg.GetConfigSection(\"mediaTypes\").(media.Types)\n\n\t// Find the target to deploy to.\n\tvar tgt *deployconfig.Target\n\tif targetName == \"\" {\n\t\t// Default to the first target.\n\t\ttgt = dcfg.Targets[0]\n\t} else {\n\t\tfor _, t := range dcfg.Targets {\n\t\t\tif t.Name == targetName {\n\t\t\t\ttgt = t\n\t\t\t}\n\t\t}\n\t\tif tgt == nil {\n\t\t\treturn nil, fmt.Errorf(\"deployment target %q not found\", targetName)\n\t\t}\n\t}\n\n\treturn &Deployer{\n\t\tlocalFs:    localFs,\n\t\ttarget:     tgt,\n\t\tquiet:      cfg.BuildExpired(),\n\t\tmediaTypes: mediaTypes,\n\t\tcfg:        dcfg,\n\t}, nil\n}\n\nfunc (d *Deployer) openBucket(ctx context.Context) (*blob.Bucket, error) {\n\tif d.bucket != nil {\n\t\treturn d.bucket, nil\n\t}\n\td.logger.Printf(\"Deploying to target %q (%s)\\n\", d.target.Name, d.target.URL)\n\treturn blob.OpenBucket(ctx, d.target.URL)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/deploy/deploy.go#L80-L116","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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."],"exampleFix":"# before\nhugo deploy --target Production   # config has name = \"production\"\n\n# after\nhugo deploy --target production","handlingStrategy":"validation","validationCode":"names := map[string]bool{}\nfor _, t := range cfg.Deployment.Targets {\n    names[t.Name] = true\n}\nif !names[flagTarget] {\n    return fmt.Errorf(\"unknown deploy target %q; available: %v\", flagTarget, maps.Keys(names))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["hugo","deploy","cli","config"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}