gohugoio/hugo · error
postcss config not found
Error message
postcss config %q not found
What it means
Thrown by the PostCSS transformer when options.Config is explicitly set by the user but the named config file cannot be resolved by BaseFs.ResolveJSConfigFile. Auto-discovered configs (postcss.config.js/mjs/cjs) never trigger this; it fires only for a missing user-specified config path.
Solutions
- Confirm the file at the path given by options["config"] exists; the error echoes the exact unresolved path.
- Use an absolute path or place postcss.config.js at the project root and remove the 'config' option to rely on auto-discovery.
- If you use Tailwind, ensure the postcss config actually loads @tailwindcss/postcss or tailwindcss plugin as intended.
Example fix
// before
{{ $css := resources.Get "css/main.css" | css.PostCSS (dict "config" "postcss/prod.config.js") }}
// after
{{ $css := resources.Get "css/main.css" | css.PostCSS }} // uses ./postcss.config.js Defensive patterns
Strategy: validation
Validate before calling
if cfg, ok := opts["config"]; ok {
p := filepath.Clean(fmt.Sprint(cfg))
if _, err := os.Stat(p); err != nil {
return fmt.Errorf("postcss config %q not found", p)
}
} Prevention
- Prefer auto-discovered postcss.config.js over an explicit 'config'.
- Commit postcss.config.js to the repo root and reference it relatively.
- Verify config paths on case-sensitive filesystems.
When it happens
Trigger: Calling css.PostCSS with options map containing "config": "./postcss/prod.js" where that path is not resolvable relative to the project working dir / JS config filesystem.
Common situations: Moving/deleting a custom postcss config without updating the template option; using a path that exists only in a different module or theme; case mismatch on case-sensitive filesystems.
Related errors
- babel config not found
- : failed to transform ( )
- cannot use --renderToMemory with --destination
- cardinalityThreshold threshold must be between 0 and 100
- could not find in the import context
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/b1047bb5c8f5cebf.
Report an issue: GitHub.
Appendix: source
Thrown at resources/resource_transformers/cssjs/postcss.go:179
if options.Config != "" {
configFile = options.Config
} else {
for _, name := range []string{"postcss.config.js", "postcss.config.mjs", "postcss.config.cjs"} {
configFile = t.rs.BaseFs.ResolveJSConfigFile(name)
if configFile != "" {
break
}
}
}
if configFile != "" {
configFile = filepath.Clean(configFile)
// We need an absolute filename to the config file.
if !filepath.IsAbs(configFile) {
configFile = t.rs.BaseFs.ResolveJSConfigFile(configFile)
if configFile == "" && options.Config != "" {
// Only fail if the user specified config file is not found.
return fmt.Errorf("postcss config %q not found", options.Config)
}
}
}
var cmdArgs []any
if configFile != "" {
infol.Logf("use config file %q", configFile)
cmdArgs = []any{"--config", configFile}
}
if optArgs := options.toArgs(); len(optArgs) > 0 {
cmdArgs = append(cmdArgs, collections.StringSliceToInterfaceSlice(optArgs)...)
}
var errBuf bytes.Buffer
stderr := io.MultiWriter(infow, &errBuf)View on GitHub (pinned to 52c9bd7908)