{"record":{"id":"baefac242faac9ab","repo":"gohugoio/hugo","slug":"too-many-arguments-expected-0-or-1","errorCode":null,"errorMessage":"too many arguments, expected 0 or 1","messagePattern":"too many arguments, expected 0 or 1","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/page__per_output.go","lineNumber":138,"sourceCode":"\t// Make sure to send the *pageState and not the *pageContentOutput to the template.\n\tres, err := executeToString(ctx, pco.po.p.s.GetTemplateStore(), templ, pco.po.p)\n\tif err != nil {\n\t\treturn \"\", pco.po.p.wrapError(fmt.Errorf(\"failed to execute template %s: %w\", templ.Name(), err))\n\t}\n\treturn template.HTML(res), nil\n}\n\nfunc (pco *pageContentOutput) Fragments(ctx context.Context) *tableofcontents.Fragments {\n\treturn pco.c().Fragments(ctx)\n}\n\nfunc (pco *pageContentOutput) RenderShortcodes(ctx context.Context) (template.HTML, error) {\n\treturn pco.c().RenderShortcodes(ctx)\n}\n\nfunc (pco *pageContentOutput) Markup(opts ...any) page.Markup {\n\tif len(opts) > 1 {\n\t\tpanic(\"too many arguments, expected 0 or 1\")\n\t}\n\tvar scope string\n\tif len(opts) == 1 {\n\t\tscope = cast.ToString(opts[0])\n\t}\n\treturn pco.po.p.m.content.getOrCreateScope(scope, pco)\n}\n\nfunc (pco *pageContentOutput) c() page.Markup {\n\treturn pco.po.p.m.content.getOrCreateScope(\"\", pco)\n}\n\nfunc (pco *pageContentOutput) Content(ctx context.Context) (any, error) {\n\tr, err := pco.c().Render(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn r.Content(ctx)","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/page__per_output.go#L120-L156","documentation":"Panic in pageContentOutput.Markup: the variadic opts slice has length > 1. The Markup method accepts zero or one argument (an optional scope string selecting a content scope); passing two or more is a usage error by the template/Go author calling it.","triggerScenarios":"Calling .Markup(a, b) or {{ .Markup \"x\" \"y\" }} from a template, or invoking pageContentOutput.Markup with multiple arguments via Go. The method signature is Markup(opts ...any) page.Markup but only 0 or 1 opt is valid.","commonSituations":"A template author calls Markup with extra arguments by mistake. Passing a slice where individual args are expected. Copy-paste from a different API. A render hook invoking Markup incorrectly.","solutions":["Call Markup with at most one argument: {{ .Markup }} or {{ .Markup \"scope\" }}.","If you need to pass multiple values, bundle them into a single scope string.","Check the template/Go call site reported in the stack trace and remove the extra argument."],"exampleFix":"{{/* before */}}\n{{ .Markup \"main\" \"extra\" }}\n\n{{/* after */}}\n{{ .Markup \"main\" }}","handlingStrategy":"validation","validationCode":"// Call Markup with 0 or 1 argument only.\n// Template:  {{ .Markup }}   or   {{ .Markup \"scope\" }}\n// Go:        pco.Markup()        pco.Markup(\"scope\")\n// If a variable number is unavoidable, slice to the first element before calling.","typeGuard":"// Limit opts before calling Markup.\nfunc safeMarkup(p MarkupProvider, opts ...any) page.Markup {\n    if len(opts) > 1 {\n        opts = opts[:1]\n    }\n    return p.Markup(opts...)\n}","tryCatchPattern":null,"preventionTips":["Pass at most one argument to Markup.","Bundle multiple values into a single scope string.","Inspect template call sites after copy-paste.","Add a template lint rule for Markup arity."],"tags":["templates","content","markup","panic","api-misuse"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}