gohugoio/hugo · error
can't apply myself (no turtles allowed)
Error message
can't apply myself (no turtles allowed)
What it means
Apply (apply.go:32-34) explicitly refuses fname == "apply" to prevent infinite recursion (the "no turtles" / no infinite-turtle-stack rule). Even if a function named apply existed, the self-call is blocked before lookup.
Solutions
- Use a real registered function name as the apply target
- For chained transformations, apply a named partial or compose funcs instead of self-application
Example fix
// before
{{ apply .Items "apply" "." }}
// after
{{ apply .Items "upper" "." }} Defensive patterns
Strategy: validation
Validate before calling
{{ $fname := "upper" }}
{{ if ne $fname "apply" }}
{{ apply . $fname "." }}
{{ end }} Prevention
- Never pass "apply" as the function name to apply
- Keep a list of allowed target function names if fname is dynamic
- Document that apply is non-recursive by design
When it happens
Trigger: {{ apply .Items "apply" "arg" }} or any call where the second argument (fname) is the literal string "apply".
Common situations: Copy-paste of an apply template that left the function name as apply; attempting to nest apply on itself for chained transformation.
Related errors
- both limit and seq must be provided
- called apply using as type
- can't find function
- can't iterate over a nil value
- can't iterate over a nil value
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/6914ef185238a331.
Report an issue: GitHub.
Appendix: source
Thrown at tpl/collections/apply.go:33
import (
"context"
"errors"
"fmt"
"reflect"
"strings"
"github.com/gohugoio/hugo/common/hreflect"
)
// Apply takes an array or slice c and returns a new slice with the function fname applied over it.
func (ns *Namespace) Apply(ctx context.Context, c any, fname string, args ...any) (any, error) {
if c == nil {
return make([]any, 0), nil
}
if fname == "apply" {
return nil, errors.New("can't apply myself (no turtles allowed)")
}
seqv := reflect.ValueOf(c)
seqv, isNil := hreflect.Indirect(seqv)
if isNil {
return nil, errors.New("can't iterate over a nil value")
}
fnv, found := ns.lookupFunc(ctx, fname)
if !found {
return nil, errors.New("can't find function " + fname)
}
switch seqv.Kind() {
case reflect.Array, reflect.Slice:
r := make([]any, seqv.Len())
for i := range seqv.Len() {
vv := seqv.Index(i)View on GitHub (pinned to 52c9bd7908)