Cascade matching on kind using glob

I host a template project based on the Docsy theme called “mostlydocs” - It uses cascade at the top level _index.md to apply a default “docs” type to all sections in the site, except for “blog” (or any other sections the user wishes):

cascade:
- _target:
    path: "/blog/**"
  type: "blog"
- _target:
    path: "/**"
  type: "docs"

This works great, except it will then also apply that type to all kinds of pages, including taxonomies (so things like /tags/foo are rendered with the wrong template).

Of course, i could add specific path targets to override those, but that would have to happen for every taxonomy (one more thing for the user of the template to remember to change should they define their own taxonomies).

Instead, it would be simpler if I could use a glob to specify exactly which kinds of pages i wish the cascade to apply to:

cascade:
- _target:
    path: "/blog/**"
  type: "blog"
- _target:
    path: "/**"
    kind: "{page,section}"
  type: "docs"

PR 7784 introduced exactly this, by allowing “kind” to match a glob rather than a string, but DecodePageMatcher seems at odds with the Matches implementation by enforcing a check to see if the supplied “kind” actually maps to a known kind.

The glob documentation was reverted, it appears in this commit, i imagine to match actual behaviour.

This leads to two questions:

  1. Is there a better way of solving my issue that doesn’t require glob kind matching at all
  2. Glob kind matching is still in the hugo source code; should DecodePageMatcher just be updated to remove that map test so it can actually be used (i tried removing it locally and it worked great)

Why not just put this in _index.md:

Cascade:
  Type: docs

And this in blog/_index.md

Cascade:
  Type:blog

?

Not sure how that helps? The end result is the same. Putting it at the top level makes it clear as a template that you can create new sections and override the type in one spot, but certainly they could override it in the section it self too.

In any event, even with your example, taxonomies would still end up with a “docs” type

If I remember correctly, there is an open bug on GitHub about this (I think I adjusted the documentation to match the current behaviour).

So, currently i guess you currently need some duplication:

- _target:
    path: "/**"
    kind: "page"
  type: "docs"
- _target:
    path: "/**"
    kind: "section"
  type: "docs"

Or something. This is unfortunate, and we will eventually fix it.

Thanks; for some reason duplicating the target hadn’t occurred to me as something that would work - That’s totally good enough for now.

Did try and find a matching issue on Github, of course; must of missed it.

I’m happy to open a PR for Hugo if you have thoughts on what the right “fix” would be

wow… i swear i searched issues… quite impressed with my own ineptitude on missing that one; apologies.