gohugoio/hugo · error
shortcode has no name
Error message
shortcode has no name
What it means
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.
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 8a468df065)
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.
Example fix
<!-- before -->
{{< >}}
<!-- after -->
{{< figure src="a.png" >}} Defensive patterns
Strategy: validation
Validate before calling
// Lint content for empty shortcode calls before build
// grep -nE '\{\{<\s*>\}\}|\{\{%\s*%\}\}' content/ -r Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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 {{</* */>}}.
Related errors
- %s: shortcode %q must be closed or self-closed
- error processing file %q
- invalid Highlight option: %s
- no earlier definition of shortcode %q found
- %s: shortcode %q does not evaluate .Inner or .InnerDeindent,
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/041eeff137597dfd.json.
Report an issue: GitHub ↗.