HUGO
Menu
GitHub 86452 stars Mastodon

Glob patterns

A glob pattern is a pattern used to match sets of values. It is a shorthand for specifying multiple targets at once, making it easier to work with groups of data or configurations.

The table below details the supported glob pattern syntax and its matching behavior. Each example illustrates a specific match type, the pattern used, and the expected boolean result when evaluated against a test string.

Match typeGlob patternTest stringMatch?
Simple wildcarda/*.mda/page.mdtrue
Literal match'a/*.md'a/*.mdtrue
Single-level wildcarda/*/page.mda/b/page.mdtrue
Single-level wildcarda/*/page.mda/b/c/page.mdfalse
Multi-level wildcarda/**/page.mda/b/c/page.mdtrue
Single characterfile.???file.txttrue
Single characterfile.???file.jsfalse
Delimiter exclusion?atf/atfalse
Character listf.[jt]xtf.txttrue
Negated listf.[!j]xtf.txttrue
Character rangef.[a-c].txtf.b.txttrue
Character rangef.[a-c].txtf.z.txtfalse
Negated rangef.[!a-c].txtf.z.txttrue
Pattern alternates*.{jpg,png}logo.pngtrue
No match*.{jpg,png}logo.webpfalse

The matching logic follows these rules:

  • Standard wildcard (*) matches any character except for a delimiter.
  • Super wildcard (**) matches any character including delimiters.
  • Single character (?) matches exactly one character, excluding delimiters.
  • Negation (!) matches any character except those specified in a list or range when used inside brackets.
  • Character ranges ([a-z]) match any single character within the specified range.

The delimiter is a slash (/), except when matching semantic version strings, where the delimiter is a dot (.).