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, err

View on GitHub ↗ (pinned to 8a468df065)

Solutions

  1. Find the empty '{{< >}}' or '{{% %}}' in the reported file and either add the shortcode name or delete the delimiters.
  2. If you meant to show literal shortcode syntax in the content, escape it as {{</* name */>}}.
  3. 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

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


AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31). Data as JSON: /data/errors/041eeff137597dfd.json. Report an issue: GitHub ↗.