gohugoio/hugo · error

no related config provided

Error message

no related config provided

What it means

Returned by related.DecodeConfig in related/inverted_index.go:561 when the config map passed in is nil. DecodeConfig runs during config load to build the related-content index configuration; a nil map means no related config was supplied at all.

Solutions

  1. Pass a non-nil (even if empty) map to DecodeConfig when building config programmatically.
  2. In hugo.toml, provide a [related] block so the loader yields a populated map.
  3. If you intentionally want no related index, supply an empty map (note that triggers error 58 instead — configure at least threshold/indices).

Example fix

// before
cfg, err := related.DecodeConfig(nil)
// after
cfg, err := related.DecodeConfig(hmaps.Params{})
Defensive patterns

Strategy: validation

Validate before calling

// Pass a non-nil related config map.
if relatedCfg == nil { relatedCfg = hmaps.Params{} }

Prevention

When it happens

Trigger: Calling related.DecodeConfig(nil) programmatically, or a config merge path that yields a nil related-config value. In normal Hugo usage the related section defaults to a non-nil map, so this typically arises from custom/embedded configs.

Common situations: An embedded Hugo build that constructs config programmatically and omits the related section, or a config loader bug that returns nil instead of an empty map.

Related errors


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

Appendix: source

Thrown at related/inverted_index.go:561

			}
		}
	}

	return result, nil
}

// normalizes num to a number between 0 and 100.
func norm(num, min, max int) int {
	if min > max {
		panic("min > max")
	}
	return int(math.Floor((float64(num-min) / float64(max-min) * 100) + 0.5))
}

// DecodeConfig decodes a slice of map into Config.
func DecodeConfig(m hmaps.Params) (Config, error) {
	if m == nil {
		return Config{}, errors.New("no related config provided")
	}

	if len(m) == 0 {
		return Config{}, errors.New("empty related config provided")
	}

	var c Config

	if err := mapstructure.WeakDecode(m, &c); err != nil {
		return c, err
	}

	if c.Threshold < 0 || c.Threshold > 100 {
		return Config{}, errors.New("related threshold must be between 0 and 100")
	}

	if c.ToLower {
		for i := range c.Indices {

View on GitHub (pinned to 52c9bd7908)