gohugoio/hugo · error

unsupported target: %v

Error message

unsupported target: %v

What it means

After trying to interpret each `target` entry as either an ES version or an engine+version, Hugo checks whether anything matched. If targets were supplied but none resolved to a known ES version (es5–es2024, esnext) or engine prefix (chrome, firefox, safari, edge, node, etc.), the whole option set is rejected as unsupported.

Source

Thrown at internal/js/esbuild/options.go:293

	var engines []api.Engine

OUTER:
	for _, value := range opts.Target {
		for _, engine := range engineKeysSorted {
			if strings.HasPrefix(value, engine) {
				version := value[len(engine):]
				if version == "" {
					return fmt.Errorf("invalid engine version: %q", value)
				}
				engines = append(engines, api.Engine{Name: engineName[engine], Version: version})
				continue OUTER
			}
		}
	}

	if target == 0 && len(engines) == 0 && len(opts.Target) > 0 {
		return fmt.Errorf("unsupported target: %v", opts.Target)
	}

	if target == 0 {
		target = api.ESNext
	}

	var loaders map[string]api.Loader
	if opts.IsCSS {
		loaders = make(map[string]api.Loader)
		// Add default CSS file loaders.
		// May be overridden by opts.Loaders.
		maps.Copy(loaders, extensionToLoaderMapCSS)
	}
	if opts.Loaders != nil {
		if loaders == nil {
			loaders = make(map[string]api.Loader)
		}

View on GitHub ↗ (pinned to 8a468df065)

Solutions

  1. Use a valid ES version ("es2015"–"es2024", "esnext") or engine+version ("chrome90", "node18", "safari15") in target.
  2. Replace browserslist-style entries — esbuild targets don't support queries or IE.
  3. Check the esbuild target docs for the exact accepted names and spell them without spaces.

Example fix

{{/* before */}}
{{ $opts := dict "target" "es7" }}
{{/* after */}}
{{ $opts := dict "target" "es2016" }}
Defensive patterns

Strategy: validation

Validate before calling

valid := map[string]bool{"es5":true,"es6":true,"es2015":true,"es2016":true,"es2017":true,"es2018":true,"es2019":true,"es2020":true,"es2021":true,"es2022":true,"es2023":true,"esnext":true}
if !valid[strings.ToLower(target)] {
    return fmt.Errorf("unsupported js.Build target %q", target)
}

Prevention

When it happens

Trigger: `js.Build` with a `target` list where every entry is unrecognized — e.g. "es7" instead of "es2016", "ie11" (esbuild has no IE engine target), or a misspelled engine like "chorme90". target != 0 or a matched engine suppresses the error, so it fires only when all entries fail to parse.

Common situations: Porting browserslist strings ("ie 11", "> 0.5%") directly into the target option; using informal ES names like es7/es8; upgrading Hugo/esbuild and using a target string from another bundler's docs.

Related errors


AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31). Data as JSON: /data/errors/234df0970d37ce85.json. Report an issue: GitHub ↗.