gohugoio/hugo · error

unsupported sourcemap type

Error message

unsupported sourcemap type: %q

What it means

Thrown when SourceMap is not one of inline, external, linked, or none (empty string is also accepted and means none).

Solutions

  1. Use: inline, external, linked, or none.

Example fix

// before
{{ $opts := dict "sourceMap" "true" }}

// after
{{ $opts := dict "sourceMap" "inline" }}
Defensive patterns

Strategy: validation

Validate before calling

switch opts.SourceMap {
case "", "inline", "external", "linked", "none":
    // ok
default:
    return fmt.Errorf("unsupported sourcemap type: %q", opts.SourceMap)
}

Prevention

When it happens

Trigger: Setting SourceMap to true, hidden, or any other string.

Common situations: User uses Webpack terminology (true, hidden); expects boolean values.

Related errors


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

Appendix: source

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

	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
	}

	sourcesContent := api.SourcesContentInclude
	if !opts.SourcesContent {
		sourcesContent = api.SourcesContentExclude
	}

	if opts.IsCSS && opts.MainFields == nil {
		opts.MainFields = []string{"style", "main"}
	}

	opts.Vars = sass.PrepareVars(opts.Vars)

	opts.compiled = api.BuildOptions{
		Outfile:       outFile,
		Bundle:        true,
		Metafile:      opts.Metafile,

View on GitHub (pinned to 52c9bd7908)