gohugoio/hugo · error
shortcode has no name
Error message
shortcode has no name
What it means
Thrown by shortcodeParseInfo.extractShortcode in hugolib/shortcode.go:601 when a left shortcode delimiter is immediately followed by a right delimiter with no name token. The parser sees {{< >}} or {{% %}} and aborts because a shortcode must name a template.
Solutions
- Search the offending content file (Hugo reports the file/line) for {{< >}} or {{% %}} and remove or complete the tag.
- Replace with the intended shortcode, e.g. {{< figure src="x.jpg" >}}.
- If you meant a literal delimiter pair, escape it or use HTML entities.
Example fix
// before
{{< >}}
// after
{{< figure src="hero.jpg" >}} Defensive patterns
Strategy: validation
Validate before calling
// Scan content for empty shortcode tags before build.
// rg -n '\\{\\{<\\s*>\\}\}|\\{\\{%\\s*%\\}\}' content/ Prevention
- Run a pre-commit grep for empty shortcode delimiters in Markdown.
- Use an editor snippet that always inserts a name placeholder inside {{< >}}.
- Treat Hugo's file/line in the error as authoritative and fix at the source.
When it happens
Trigger: Authoring Markdown content containing an empty shortcode tag {{< >}} or {{% %}}, or a partial edit that deleted the shortcode name but left the delimiters.
Common situations: Typing a shortcode and accidentally closing it before the name, find-and-replace that emptied a shortcode name, or copy-pasting a shortcode skeleton without filling it in.
Related errors
- failed to render shortcode
- no template found for shortcode
- process
- : invalid state: invalid param type %T for shortcode …
- : invalid state: invalid param type %T for shortcode …
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/041eeff137597dfd.
Report an issue: GitHub.
Appendix: source
Thrown at hugolib/shortcode.go:601
sc.indentation = item.ValStr(source)
}
}
cnt := 0
nestedOrdinal := 0
nextLevel := level + 1
closed := false
const errorPrefix = "failed to extract shortcode"
Loop:
for {
currItem := pt.Next()
switch {
case currItem.IsLeftShortcodeDelim():
next := pt.Peek()
if next.IsRightShortcodeDelim() {
// no name: {{< >}} or {{% %}}
return sc, errors.New("shortcode has no name")
}
if next.IsShortcodeClose() {
continue
}
if cnt > 0 {
// nested shortcode; append it to inner content
pt.Backup()
nested, err := s.extractShortcode(nestedOrdinal, nextLevel, source, pt)
nestedOrdinal++
if nested != nil && nested.name != "" {
s.addName(nested.name)
}
if err == nil {
sc.inner = append(sc.inner, nested)
} else {
return sc, errView on GitHub (pinned to 52c9bd7908)