gohugoio/hugo · error

unsupported drop type: %q

Error message

unsupported drop type: %q

What it means

The `drop` option tells esbuild to strip constructs from the output. Hugo supports exactly one of "console" (remove console.* calls) or "debugger" (remove debugger statements), or empty for none; any other value produces this error. Note esbuild itself allows both simultaneously, but Hugo's option is a single string.

Source

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

	default:
		err = fmt.Errorf("unsupported platform type: %q", opts.Platform)
		return
	}

	var defines map[string]string
	if opts.Defines != nil {
		defines = hmaps.ToStringMapString(opts.Defines)
	}

	var drop api.Drop
	switch opts.Drop {
	case "":
	case "console":
		drop = api.DropConsole
	case "debugger":
		drop = api.DropDebugger
	default:
		err = fmt.Errorf("unsupported drop type: %q", opts.Drop)
	}

	// By default we only need to specify outDir and no outFile
	outDir := opts.OutDir
	outFile := ""
	var sourceMap api.SourceMap
	switch opts.SourceMap {
	case "inline":
		sourceMap = api.SourceMapInline
	case "external":
		sourceMap = api.SourceMapExternal
	case "linked":
		sourceMap = api.SourceMapLinked
	case "", "none":
		sourceMap = api.SourceMapNone
	default:
		err = fmt.Errorf("unsupported sourcemap type: %q", opts.SourceMap)
		return

View on GitHub ↗ (pinned to 8a468df065)

Solutions

  1. Set drop to exactly "console" or "debugger".
  2. If you need both dropped, drop "console" via this option and rely on minification/manual removal for debugger statements, or open a feature request — Hugo currently accepts only one.
  3. Remove the option if you don't need stripping.

Example fix

{{/* before */}}
{{ $js := resources.Get "main.js" | js.Build (dict "drop" "console,debugger") }}
{{/* after */}}
{{ $js := resources.Get "main.js" | js.Build (dict "drop" "console") }}
Defensive patterns

Strategy: validation

Validate before calling

validDrop := map[string]bool{"": true, "console": true, "debugger": true}
if !validDrop[opts.Drop] {
    return fmt.Errorf("invalid drop option %q; must be console or debugger", opts.Drop)
}

Prevention

When it happens

Trigger: Passing `dict "drop" "console,debugger"`, "logs", or an array to js.Build/js.Batch; any value other than "", "console", "debugger".

Common situations: Trying to drop both console and debugger in one option (esbuild CLI style `--drop:console --drop:debugger` doesn't map to Hugo's single-string option); typos like "consoles" or "console.log".

Related errors


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