gohugoio/hugo · error

requires numeric arguments

Error message

requires numeric arguments

What it means

Thrown by math.Atan2 (tpl/math/math.go:92) when the FIRST argument (n) cannot be converted to float64. Atan2 takes two operands and computes atan2(n, m); the message uses the plural 'arguments' but the line corresponds to the n conversion failing.

Source

Thrown at tpl/math/math.go:92

		return 0, errors.New("requires a numeric argument")
	}
	return math.Asin(af), nil
}

// Atan returns the arctangent, in radians, of n.
func (ns *Namespace) Atan(n any) (float64, error) {
	af, err := cast.ToFloat64E(n)
	if err != nil {
		return 0, errors.New("requires a numeric argument")
	}
	return math.Atan(af), nil
}

// Atan2 returns the arc tangent of n/m, using the signs of the two to determine the quadrant of the return value.
func (ns *Namespace) Atan2(n, m any) (float64, error) {
	afx, err := cast.ToFloat64E(n)
	if err != nil {
		return 0, errors.New("requires numeric arguments")
	}
	afy, err := cast.ToFloat64E(m)
	if err != nil {
		return 0, errors.New("requires numeric arguments")
	}
	return math.Atan2(afx, afy), nil
}

// Ceil returns the least integer value greater than or equal to n.
func (ns *Namespace) Ceil(n any) (float64, error) {
	xf, err := cast.ToFloat64E(n)
	if err != nil {
		return 0, errors.New("Ceil operator can't be used with non-float value")
	}

	return math.Ceil(xf), nil
}

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Ensure the first argument is numeric (it represents the y-coordinate in atan2(y, x)).
  2. Add a numeric default to the first arg.
  3. Verify argument order matches atan2(y, x) convention.
  4. Fix the source field to be numeric.

Example fix

// before
{{ math.Atan2 .Params.yLabel .Params.x }}

// after
{{ $y := .Params.y | default 0 }}
{{ $x := .Params.x | default 1 }}
{{ math.Atan2 $y $x }}
Defensive patterns

Strategy: type-guard

Validate before calling

// Validate the FIRST (y) operand before math.Atan2(y, x):
{{ $y := .Param "y" | default 0 }}
{{ $x := .Param "x" | default 1 }}
{{ math.Atan2 $y $x }}

Type guard

// Reuse the isNumeric guard from errorIndex 148 on the first argument of math.Atan2.

Prevention

When it happens

Trigger: Calling {{ math.Atan2 .Y .X }} where .Y (the first arg) is non-numeric; passing a text/nil/bool value as the first operand.

Common situations: Wrong argument order (passing a non-numeric field first); nil param; type drift in source data.

Related errors


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