{"record":{"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":"validation","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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/deploy/deploy.go#L80-L116","documentation":"deploy.New (deploy/deploy.go:88) selects the deployment target by name (from the --target flag). If a name is given and no entry in dcfg.Targets (the [[deployment.targets]] list) matches it, Hugo cannot proceed and returns this error. With an empty name it defaults to the first target.","triggerScenarios":"`hugo deploy --target=foo` where 'foo' is not among the configured [[deployment.targets]] names; deploying before any target is defined; case/whitespace mismatch in the name.","commonSituations":"Typo in the --target value; forgetting to add the target to config; renaming a target but not the flag; copy-pasting a deploy command from a different project.","solutions":["List the [[deployment.targets]] names in your config and correct the --target spelling/whitespace/case.","Add the missing [[deployment.targets]] entry with the desired name.","Omit --target to deploy to the first defined target.","Ensure at least one target is configured (otherwise you get the separate 'no deployment targets found' error)."],"exampleFix":"# before\n$ hugo deploy --target=prod   # config only defines 'production'\n\n# after\n$ hugo deploy --target=production","handlingStrategy":"validation","validationCode":"// Verify a target name exists in config before `hugo deploy --target=...`.\nfunc ValidateDeployTarget(targets []deployconfig.Target, name string) error {\n    if name == \"\" { return nil } // empty -> first target\n    for _, t := range targets {\n        if t.Name == name { return nil }\n    }\n    return fmt.Errorf(\"deployment target %q not found\", name)\n}","typeGuard":null,"tryCatchPattern":"d, err := deploy.New(cfg, fs, targetName, logger)\nif err != nil {\n    return err\n}","preventionTips":["Keep deploy scripts and [[deployment.targets]] names in sync.","Trim/normalise the --target value.","Document the canonical target names in the project README."],"tags":["deploy","config"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}