gohugoio/hugo · error

did not match a valid Page Kind

Error message

%q did not match a valid Page Kind

What it means

Returned by decodePageMatcher when the Kind field (after lowercasing) does not match any valid Hugo Page Kind via glob matching against kinds.AllKindsInPages. Hugo supports glob patterns in the Kind field, so 'page' matches, 'sec*' matches 'section', but 'article' (not a Hugo kind) does not match anything.

Solutions

  1. Check the error message for the invalid kind value, then use a valid Hugo Page Kind: home, page, section, taxonomy, or term.
  2. Use a glob pattern if you want to match multiple kinds, e.g. '{page,section}' or '*'.
  3. Omit the kind field entirely to match all kinds.

Example fix

# before
cascade:
  - _target:
      kind: "article"
    params:
      toc: true

# after
cascade:
  - _target:
      kind: "page"
    params:
      toc: true
Defensive patterns

Strategy: validation

Validate before calling

// Validate a cascade target kind before decoding
func validatePageKind(kind string) error {
    kind = strings.ToLower(kind)
    if kind == "" { return nil }
    g, err := hglob.GetGlob(kind)
    if err != nil { return err }
    found := slices.ContainsFunc(kinds.AllKindsInPages, g.Match)
    if !found {
        return fmt.Errorf("kind %q did not match a valid Page Kind", kind)
    }
    return nil
}

// Valid Hugo page kinds: home, page, section, taxonomy, term

Prevention

When it happens

Trigger: Setting target.kind in a cascade to a string that is not a valid Page Kind or glob matching one. Valid kinds include: home, page, section, taxonomy, term, and their combinations. The value is lowercased and compiled as a glob before matching.

Common situations: Using 'article' instead of 'page' (common for users coming from other CMSs); using 'category' instead of 'taxonomy' or 'term'; typo like 'pagge'; using a singular when Hugo expects plural ('section' not 'sections').

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/c75c9f5cc48d4744. Report an issue: GitHub.

Appendix: source

Thrown at resources/page/page_matcher.go:244

		default:
			pcfg.Fields[k] = v
		}
	}
	return pcfg, pcfg.init()
}

// decodePageMatcher decodes m into v.
func (d cascadeConfigDecoder) decodePageMatcher(m any, v *PageMatcher) error {
	if err := mapstructure.WeakDecode(m, v); err != nil {
		return err
	}

	v.Kind = strings.ToLower(v.Kind)
	if v.Kind != "" {
		g, _ := hglob.GetGlob(v.Kind)
		found := slices.ContainsFunc(kinds.AllKindsInPages, g.Match)
		if !found {
			return fmt.Errorf("%q did not match a valid Page Kind", v.Kind)
		}
	}

	v.Path = filepath.ToSlash(strings.ToLower(v.Path))

	if v.Lang != "" {
		v.Sites.Matrix.Languages = append(v.Sites.Matrix.Languages, v.Lang)
		v.Sites.Matrix.Languages = hstrings.UniqueStringsReuse(v.Sites.Matrix.Languages)
	}

	return nil
}

func (v *PageMatcher) compileGlobs() error {
	var err error
	if v.Kind != "" {
		v.kindGlob, err = hglob.GetGlob(v.Kind)
		if err != nil {

View on GitHub (pinned to 52c9bd7908)