gohugoio/hugo · error

you need to install Go to use it. See https://golang.org/dl

Error message

 you need to install Go to use it. See https://golang.org/dl/ : %q

What it means

Returned by wrapModuleNotFound (modules/collect.go:897) when c.goBinaryStatus == goBinaryStatusNotFound. This status is set in client.go:793 when executing the 'go' command yields exec.ErrNotFound. Because a go.mod is present but the Go toolchain is absent, Hugo cannot resolve module dependencies and tells the user to install Go.

Source

Thrown at modules/collect.go:897

	}

	return out, nil
}

func (c *collector) wrapModuleNotFound(err error) error {
	if c.Client.ccfg.IgnoreModuleDoesNotExist {
		return nil
	}
	err = fmt.Errorf(err.Error()+": %w", ErrNotExist)
	if c.GoModulesFilename == "" {
		return err
	}

	baseMsg := "we found a go.mod file in your project, but"

	switch c.goBinaryStatus {
	case goBinaryStatusNotFound:
		return fmt.Errorf(baseMsg+" you need to install Go to use it. See https://golang.org/dl/ : %q", err)
	case goBinaryStatusTooOld:
		return fmt.Errorf(baseMsg+" you need to a newer version of Go to use it. See https://golang.org/dl/ : %w", err)
	}

	return err
}

type vendoredModule struct {
	Owner   Module
	Dir     string
	Version string
}

func createProjectModule(gomod *goModule, workingDir string, conf Config) *moduleAdapter {
	// Create a pseudo module for the main project.
	var path string
	if gomod == nil {
		path = "project"

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Install Go from https://go.dev/dl/ (or your package manager, e.g. apt/brew) and ensure 'go version' succeeds on PATH.
  2. If you do not need module support, remove the go.mod / avoid module.imports so Hugo does not invoke go.
  3. Pre-vendor dependencies with 'hugo vendor' on a machine that has Go, then build without Go elsewhere.

Example fix

// verify Go is available before building
// before: go.mod present, no go binary -> error
// after
go version   // ensure prints a version
hugo mod tidy
hugo
Defensive patterns

Strategy: validation

Validate before calling

// preflight: assert go is on PATH when a go.mod exists
if _, err := os.Stat(filepath.Join(workDir, "go.mod")); err == nil {
    if _, err := exec.LookPath("go"); err != nil {
        return errors.New("go.mod present but 'go' binary not found on PATH; install Go")
    }
}

Prevention

When it happens

Trigger: A go.mod exists in the project (or a theme/module requires the Go module integration), Hugo invokes the go binary to download modules, and the go executable is not on PATH.

Common situations: CI/container images that include Hugo but not Go; local machines where Go was never installed or was uninstalled; PATH not updated after installing Go via a version manager; deploying Hugo in environments expecting only pre-built assets.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/9eeea73843241800. Report an issue: GitHub.