Debian Codegraph @

docs/content/en/functions/resources/GetMatch.md

raw
1 ---
2 title: resources.GetMatch
3 description: Returns the first global resource from paths matching the given glob pattern, or nil if none found.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: []
9 returnType: resource.Resource
10 signatures: [resources.GetMatch PATTERN]
11 ---
12
13 ```go-html-template
14 {{ with resources.GetMatch "images/*.jpg" }}
15 <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
16 {{ end }}
17 ```
18
19 > [!NOTE]
20 > This function operates on global resources. A global resource is a file within the `assets` directory, or within any directory mounted to the `assets` directory.
21 >
22 > For page resources, use the [`Resources.GetMatch`][] method on a `Page` object.
23
24 Hugo determines a match using a case-insensitive [glob pattern](g). For syntax rules and examples, see the [glob patterns quick reference guide][].
25
26 [`Resources.GetMatch`]: /methods/page/resources/#getmatch
27 [glob patterns quick reference guide]: /quick-reference/glob-patterns/