gohugoio/hugo · error

no such operator

Error message

no such operator

What it means

The where function's third form takes an operator string; checkCondition dispatches on it and returns this error for anything outside the supported set (=/==/eq, !=/<>/ne, >=/ge, >/gt, <=/le, </lt, in, not in, intersect, like). An unrecognized operator string falls through to the default case.

Source

Thrown at tpl/collections/where.go:307

			if s.Len() > 0 {
				return true, nil
			}
			return false, nil
		}
		return false, errors.New("invalid intersect values")
	case "like":
		if svp != nil && smvp != nil {
			re, err := hstrings.GetOrCompileRegexp(*smvp)
			if err != nil {
				return false, err
			}
			if re.MatchString(*svp) {
				return true, nil
			}
			return false, nil
		}
	default:
		return false, errors.New("no such operator")
	}
	return false, nil
}

func evaluateSubElem(ctx, obj reflect.Value, elemName string) (reflect.Value, error) {
	if !obj.IsValid() {
		return zero, errors.New("can't evaluate an invalid value")
	}

	typ := obj.Type()
	obj, isNil := hreflect.Indirect(obj)

	// first, check whether obj has a method. In this case, obj is
	// a struct or its pointer. If obj is a struct,
	// to check all T and *T method, use obj pointer type Value
	objPtr := obj
	if !hreflect.IsInterfaceOrPointer(objPtr.Kind()) && objPtr.CanAddr() {
		objPtr = objPtr.Addr()

View on GitHub ↗ (pinned to 8a468df065)

Solutions

  1. Use one of the supported operators exactly: eq/ne/ge/gt/le/lt (or symbol forms), "in", "not in", "intersect", "like" — lowercase.
  2. If you meant plain equality, drop the operator: {{ where $pages "Section" "blog" }}.
  3. If using "like", confirm your Hugo version supports it (upgrade if not).

Example fix

{{/* before */}}
{{ $posts := where .Site.RegularPages "Section" "===" "blog" }}

{{/* after */}}
{{ $posts := where .Site.RegularPages "Section" "eq" "blog" }}
Defensive patterns

Strategy: validation

Validate before calling

{{/* Use only supported where operators */}}
{{ $ops := slice "=" "==" "eq" "!=" "<>" "ne" ">=" "ge" ">" "gt" "<=" "le" "<" "lt" "in" "not in" "intersect" "like" }}
{{ $op := "in" }}
{{ if not (in $ops $op) }}{{ errorf "unsupported where operator %q" $op }}{{ end }}
{{ $r := where site.RegularPages "Params.tag" $op (slice "go") }}

Prevention

When it happens

Trigger: {{ where $c "key" "op" $v }} with an unsupported or misspelled operator — e.g. "===", "contains", "NOT IN" (operators are case-sensitive lowercase), "notin", "=~", or accidentally passing the match value in the operator position in the 3-arg vs 4-arg form.

Common situations: Developers from other ecosystems try SQL/JS-style operators; using the 4-argument form when the 3-argument (implicit equality) form was intended shifts the value into the operator slot; "like" only exists in newer Hugo versions, so older Hugo rejects it too.

Related errors


AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31). Data as JSON: /data/errors/972d28e7e8d65610.json. Report an issue: GitHub ↗.