{"record":{"id":"c515da0891620837","repo":"gohugoio/hugo","slug":"want-1-or-2-arguments","errorCode":null,"errorMessage":"want 1 or 2 arguments","messagePattern":"want 1 or 2 arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/page__content.go","lineNumber":882,"sourceCode":"\tctx = c.prepareContext(ctx)\n\tcr, err := c.contentRendered(ctx)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn cr.contentWithoutSummary, nil\n}\n\nfunc (c *cachedContentScope) Summary(ctx context.Context) (page.Summary, error) {\n\tctx = c.prepareContext(ctx)\n\trendered, err := c.contentRendered(ctx)\n\treturn rendered.summary, err\n}\n\nfunc (c *cachedContentScope) RenderString(ctx context.Context, args ...any) (template.HTML, error) {\n\tctx = c.prepareContext(ctx)\n\n\tif len(args) < 1 || len(args) > 2 {\n\t\treturn \"\", errors.New(\"want 1 or 2 arguments\")\n\t}\n\n\tpco := c.pco\n\n\tvar contentToRender string\n\topts := defaultRenderStringOpts\n\tsidx := 1\n\n\tif len(args) == 1 {\n\t\tsidx = 0\n\t} else {\n\t\tm, ok := args[0].(map[string]any)\n\t\tif !ok {\n\t\t\treturn \"\", errors.New(\"first argument must be a map\")\n\t\t}\n\n\t\tif err := mapstructure.WeakDecode(m, &opts); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to decode options: %w\", err)","sourceCodeStart":864,"sourceCodeEnd":900,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/page__content.go#L864-L900","documentation":"Page.RenderString accepts either one argument (the content string) or two arguments (an options map followed by the content string). Any other count — zero arguments, or three or more — returns this error.","triggerScenarios":"{{ .RenderString }} with no arguments, or a call passing three or more positional arguments.","commonSituations":"Forgetting to pass the content string to RenderString; passing extra positional args by mistake in a partial.","solutions":["Pass exactly one argument (the content) or two (options map, content).","Remove any extra positional arguments.","If you only need default rendering, pass the string alone."],"exampleFix":"// before\n{{ .RenderString }}\n// after\n{{ .RenderString \"**hello**\" }}","handlingStrategy":"validation","validationCode":"// RenderString wants 1 or 2 args\nif len(args) < 1 || len(args) > 2 {\n    return errors.New(\"RenderString: pass the content, or an options map plus the content\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass exactly the content string, or a map plus the content.","Avoid extra positional arguments in partial calls.","Document RenderString arg shapes for template authors."],"tags":["hugo","template","renderstring"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}