{"record":{"id":"39ceb931a8110bde","repo":"gohugoio/hugo","slug":"s-invalid-state-invalid-param-type-t-for-short","errorCode":null,"errorMessage":"%s: invalid state: invalid param type %T for shortcode %q, expected a map","messagePattern":"(.+?): invalid state: invalid param type %T for shortcode %q, expected a map","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/shortcode.go","lineNumber":690,"sourceCode":"\t\t\t}\n\t\t\tsc.templ = templ\n\t\tcase currItem.IsInlineShortcodeName():\n\t\t\tsc.name = currItem.ValStr(source)\n\t\t\tsc.isInline = true\n\t\tcase currItem.IsShortcodeParam():\n\t\t\tif !pt.IsValueNext() {\n\t\t\t\tcontinue\n\t\t\t} else if pt.Peek().IsShortcodeParamVal() {\n\t\t\t\t// named params\n\t\t\t\tif sc.params == nil {\n\t\t\t\t\tparams := make(map[string]any)\n\t\t\t\t\tparams[currItem.ValStr(source)] = pt.Next().ValTyped(source)\n\t\t\t\t\tsc.params = params\n\t\t\t\t} else {\n\t\t\t\t\tif params, ok := sc.params.(map[string]any); ok {\n\t\t\t\t\t\tparams[currItem.ValStr(source)] = pt.Next().ValTyped(source)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn sc, fmt.Errorf(\"%s: invalid state: invalid param type %T for shortcode %q, expected a map\", errorPrefix, params, sc.name)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// positional params\n\t\t\t\tif sc.params == nil {\n\t\t\t\t\tvar params []any\n\t\t\t\t\tparams = append(params, currItem.ValTyped(source))\n\t\t\t\t\tsc.params = params\n\t\t\t\t} else {\n\t\t\t\t\tif params, ok := sc.params.([]any); ok {\n\t\t\t\t\t\tparams = append(params, currItem.ValTyped(source))\n\t\t\t\t\t\tsc.params = params\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn sc, fmt.Errorf(\"%s: invalid state: invalid param type %T for shortcode %q, expected a slice\", errorPrefix, params, sc.name)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase currItem.IsDone():","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/shortcode.go#L672-L708","documentation":"Hugo's shortcode parser detected an internal state inconsistency while collecting named (key=value) parameters: the shortcode's accumulated params field was already assigned a non-map value (typically a positional []any slice from earlier positional args). The parser expected a map[string]any because the current token is a named parameter, but the prior params do not match that type. This indicates the shortcode invocation mixes named and positional parameter styles in a way the parser cannot reconcile.","triggerScenarios":"A shortcode call that interleaves positional and named arguments, e.g. {{< mysc positionalval key=\"x\" >}}, where the first token was parsed as positional (setting sc.params to []any) and a subsequent key=value token is then treated as a named param. The mismatch at shortcode.go:687-690 returns this error.","commonSituations":"Authoring a shortcode and forgetting to keep a single parameter style; copy-pasting a shortcode invocation and partially editing it to add a key=value while leaving positional values; upgrading Hugo where tokenization rules around params changed.","solutions":["Audit the failing shortcode invocation and convert all parameters to one style: either all positional (space-separated values) or all named (key=\"value\").","Check the shortcode template definition (layouts/shortcodes/<name>.html) to confirm which style .Get expects, then match the invocation to it.","If you need both, redesign the shortcode to accept a single style and derive the rest internally.","Run hugo --renderToMemory or hugo server and read the error prefix (%s:) to find the exact file/line of the offending invocation."],"exampleFix":"// before\n{{< mysc foo bar=\"baz\" >}}\n\n// after (all named)\n{{< mysc first=\"foo\" bar=\"baz\" >}}\n// or (all positional)\n{{< mysc foo baz >}}","handlingStrategy":"validation","validationCode":"// Before rendering content, lint each shortcode invocation for mixed styles.\n// (Conceptual Go check over parsed shortcode tokens.)\nfunc validateShortcodeParams(tokens []scToken) error {\n    seenNamed, seenPositional := false, false\n    for _, t := range tokens {\n        if t.isNamedParam()  { seenNamed = true }\n        if t.isPositional()  { seenPositional = true }\n        if seenNamed && seenPositional {\n            return fmt.Errorf(\"shortcode %q mixes named and positional params\", tokens[0].name)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize each shortcode template on exactly one parameter style and document it.","Run hugo in CI to catch shortcode param errors before deploy.","When editing shortcode invocations, re-read the template to confirm the expected style."],"tags":["shortcode","template","parsing","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}