{"id":"041eeff137597dfd","repo":"gohugoio/hugo","slug":"shortcode-has-no-name","errorCode":null,"errorMessage":"shortcode has no name","messagePattern":"shortcode has no name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/shortcode.go","lineNumber":601,"sourceCode":"\t\t\tsc.indentation = item.ValStr(source)\n\t\t}\n\t}\n\n\tcnt := 0\n\tnestedOrdinal := 0\n\tnextLevel := level + 1\n\tclosed := false\n\tconst errorPrefix = \"failed to extract shortcode\"\n\nLoop:\n\tfor {\n\t\tcurrItem := pt.Next()\n\t\tswitch {\n\t\tcase currItem.IsLeftShortcodeDelim():\n\t\t\tnext := pt.Peek()\n\t\t\tif next.IsRightShortcodeDelim() {\n\t\t\t\t// no name: {{< >}} or {{% %}}\n\t\t\t\treturn sc, errors.New(\"shortcode has no name\")\n\t\t\t}\n\t\t\tif next.IsShortcodeClose() {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif cnt > 0 {\n\t\t\t\t// nested shortcode; append it to inner content\n\t\t\t\tpt.Backup()\n\t\t\t\tnested, err := s.extractShortcode(nestedOrdinal, nextLevel, source, pt)\n\t\t\t\tnestedOrdinal++\n\t\t\t\tif nested != nil && nested.name != \"\" {\n\t\t\t\t\ts.addName(nested.name)\n\t\t\t\t}\n\n\t\t\t\tif err == nil {\n\t\t\t\t\tsc.inner = append(sc.inner, nested)\n\t\t\t\t} else {\n\t\t\t\t\treturn sc, err","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/shortcode.go#L583-L619","documentation":"While extracting shortcodes from page content, Hugo saw an opening shortcode delimiter immediately followed by the closing delimiter — i.e. '{{< >}}' or '{{% %}}' with nothing in between. A shortcode call must name the shortcode to invoke, so the parser aborts with this error at that position.","triggerScenarios":"Content containing an empty shortcode call: '{{< >}}', '{{% %}}', typically from an accidental keystroke, a templating mishap that emitted empty delimiters, or deleting a shortcode name while leaving the delimiters.","commonSituations":"Half-deleted shortcode calls during editing; content generated by scripts/migrations that interpolate an empty variable into the shortcode name slot; find-and-replace operations that stripped names; documentation examples of shortcode syntax not escaped with {{</* */>}}.","solutions":["Find the empty '{{< >}}' or '{{% %}}' in the reported file and either add the shortcode name or delete the delimiters.","If you meant to show literal shortcode syntax in the content, escape it as {{</* name */>}}.","If content is machine-generated, fix the generator so it never emits delimiters with an empty name."],"exampleFix":"<!-- before -->\n{{< >}}\n\n<!-- after -->\n{{< figure src=\"a.png\" >}}","handlingStrategy":"validation","validationCode":"// Lint content for empty shortcode calls before build\n// grep -nE '\\{\\{<\\s*>\\}\\}|\\{\\{%\\s*%\\}\\}' content/ -r","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never emit {{< >}} or {{% %}} with no name — templating that generates content must always interpolate a shortcode name","Add a CI grep for empty shortcode delimiters in content files","When generating Markdown programmatically, validate the shortcode name is non-empty before writing"],"tags":["hugo","shortcode","content","parsing"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}