gohugoio/hugo · error
failed to parse timeout: %s
Error message
failed to parse timeout: %s
What it means
During `Config.CompileConfig`, Hugo parses the `timeout` setting. A bare integer is treated as seconds (it appends "s"), otherwise the value must be a valid Go `time.ParseDuration` string like "30s" or "2m". Anything else fails compilation with this error.
Source
Thrown at config/allconfig/allconfig.go:279
x.StaticDir6 = nil
x.StaticDir7 = nil
x.StaticDir8 = nil
x.StaticDir9 = nil
x.StaticDir10 = nil
return &x
}
func (c *Config) CompileConfig(logger loggers.Logger) error {
var transientErr error
s := c.Timeout
if _, err := strconv.Atoi(s); err == nil {
// A number, assume seconds.
s = s + "s"
}
timeout, err := time.ParseDuration(s)
if err != nil {
return fmt.Errorf("failed to parse timeout: %s", err)
}
disabledKinds := make(map[string]bool)
for _, kind := range c.DisableKinds {
kind = strings.ToLower(kind)
if newKind := kinds.IsDeprecatedAndReplacedWith(kind); newKind != "" {
logger.Deprecatef(false, "Kind %q used in disableKinds is deprecated, use %q instead.", kind, newKind)
// Legacy config.
kind = newKind
}
if kinds.GetKindAny(kind) == "" {
logger.Warnf("Unknown kind %q in disableKinds configuration.", kind)
continue
}
disabledKinds[kind] = true
}
kindOutputFormats := make(map[string]output.Formats)
isRssDisabled := disabledKinds["rss"]
outputFormats := c.OutputFormats.ConfigView on GitHub ↗ (pinned to 8a468df065)
Solutions
- Use a Go duration string: `timeout = "60s"`, `"2m"`, `"1h"`.
- Or use a plain integer, which Hugo interprets as seconds: `timeout = 120`.
- Check theme/module configs too — the merged value may come from a dependency (`hugo config | grep -i timeout`).
Example fix
# before (hugo.toml) timeout = "30 seconds" # after timeout = "30s"
Defensive patterns
Strategy: validation
Validate before calling
if _, err := time.ParseDuration(timeoutStr); err != nil {
if _, err2 := strconv.Atoi(timeoutStr); err2 != nil {
return fmt.Errorf("invalid timeout %q: use a Go duration like \"30s\"", timeoutStr)
}
} Prevention
- Set timeout as a Go duration string ("30s", "2m") or plain milliseconds integer
- Validate user-supplied config values with time.ParseDuration before writing them into the config map
- Avoid units like "30 sec" or locale-formatted numbers
When it happens
Trigger: A `timeout` value in site config that is neither an integer nor a valid duration string — e.g. `timeout = "30 seconds"`, `timeout = "1h30"`, or a float like `"2.5"` without a unit suffix.
Common situations: Users writing human-style durations ("1 minute"), copying values from other tools, or old configs using milliseconds-as-number assumptions; note plain numbers were interpreted as milliseconds before Hugo 0.86 and as seconds after.
Related errors
- errConfigNotSet
- failed to compile whitelist pattern %q: %w
- failed to load config: %v
- failed to init config: %w
- no filesystem provided
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/6577fc45d50834aa.json.
Report an issue: GitHub ↗.