gohugoio/hugo · error
origin must be /
Error message
origin must be <project>/<origin>
What it means
InvalidateGoogleCloudCDN (deploy/google.go:28, built only with the 'withdeploy' tag) splits the origin string on '/' and requires exactly two parts: <GCP project>/<CDN origin name>. It then calls compute.UrlMaps.InvalidateCache(project, origin). This fires when GoogleCloudCDNOrigin is missing the slash, has multiple slashes, or is empty-ish.
Solutions
- Set googleCloudCDNOrigin to exactly '<project>/<origin>', e.g. 'my-gcp-project/my-load-balancer-origin'.
- Ensure no leading/trailing slash and exactly one separating slash.
- If you do not use Google Cloud CDN, leave googleCloudCDNOrigin empty.
Example fix
# before [[deployment.targets]] name = "gcp" googleCloudCDNOrigin = "my-project" # after [[deployment.targets]] name = "gcp" googleCloudCDNOrigin = "my-project/my-origin"
Defensive patterns
Strategy: validation
Validate before calling
// Enforce the <project>/<origin> shape before deploying.
func ValidateGoogleCDNOrigin(origin string) error {
parts := strings.Split(origin, "/")
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
return fmt.Errorf("origin must be <project>/<origin>, got %q", origin)
}
return nil
} Try / catch
if err := deploy.InvalidateGoogleCloudCDN(ctx, origin); err != nil {
return err
} Prevention
- Set googleCloudCDNOrigin to exactly '<project>/<origin>'.
- Leave it empty if you don't use Google Cloud CDN.
- Validate the value in CI before deploy.
When it happens
Trigger: Setting a target's googleCloudCDNOrigin to 'myproject' (no slash), 'a/b/c' (two slashes), or '/origin' (empty project); the value flows from deployconfig.Target.GoogleCloudCDNOrigin through deploy.go:290.
Common situations: Confusing the origin format with a URL or a bare origin name; copy-pasting a CloudFront distribution id into the Google field.
Related errors
- deployment target not found
- empty deployment matcher
- empty deployment target
- invalid deployment.matchers.pattern
- invalid deployment.orderings.pattern
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/7bf481753ade4b08.
Report an issue: GitHub.
Appendix: source
Thrown at deploy/google.go:30
// limitations under the License.
//go:build withdeploy
package deploy
import (
"context"
"fmt"
"strings"
"google.golang.org/api/compute/v1"
)
// Invalidate all of the content in a Google Cloud CDN distribution.
func InvalidateGoogleCloudCDN(ctx context.Context, origin string) error {
parts := strings.Split(origin, "/")
if len(parts) != 2 {
return fmt.Errorf("origin must be <project>/<origin>")
}
service, err := compute.NewService(ctx)
if err != nil {
return err
}
rule := &compute.CacheInvalidationRule{Path: "/*"}
_, err = service.UrlMaps.InvalidateCache(parts[0], parts[1], rule).Context(ctx).Do()
return err
}
View on GitHub (pinned to 52c9bd7908)