Open navClose nav

Working with Globs

Certain configuration values in Forestry, such as the sidebar match and exclude parameters, accept what is known as a glob. A glob is a string of characters that follows a special syntax, used to match paths in a file tree.

Basic Syntax

  • ? matches a single character
  • * matches any number of characters.
  • [abc] matches any one character in the given set
  • [a-z] matches a range.
  • {foo,bar} matches any whole word in the given set


Two asterisks in sequence (**) is known as a globstar and will match 0 or more subdirectories in the path.

For example, the pattern /content/**/ matches all of the following:

  • /content/
  • /content/posts/
  • /content/authors/
  • /content/products/clothing/

Practical Examples

The following are examples of some patterns you might use in your sidebar configuration’s match or exclude field.

Pattern Matches
/data/*.json All JSON files in the data directory
/data/**/*.json All JSON files in the data directory and any subdirectories
**/*.{yaml,yml,json,toml} All JSON, YAML, or TOML files in the entire project
{/foo.json,/data/bar.toml} Only /foo.json and /data/bar.toml

Further Reading

Last updated on November 13, 2018