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)
returnView on GitHub ↗ (pinned to 8a468df065)
Solutions
- Set drop to exactly "console" or "debugger".
- 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.
- 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
- drop accepts only console or debugger — it is a single string in Hugo, not a list like raw esbuild.
- Gate drop behind a production flag (e.g. hugo.IsProduction) so dev builds keep console output.
- Don't copy esbuild JS-API config verbatim; Hugo's option names/shapes differ slightly.
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
- inject: absolute paths not supported, must be relative to /a
- invalid engine version: %q
- unsupported target: %v
- invalid loader: %q
- unsupported script output format: %q
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/c9c66d8977a8d326.json.
Report an issue: GitHub ↗.