GetMatch finds the first Resource matching the given pattern, or nil if none found. See Match for a more complete explanation about the rules used.
Match gets all resources matching the given base path prefix, e.g “.png” will match all png files. The “” does not match path delimiters (/), so if you organize your resources in sub-folders, you need to be explicit about it, e.g.: “images/*.png”. To match any PNG image anywhere in the bundle you can do “**.png”, and to match all PNG images below the images folder, use “images/**.jpg”. The matching is case insensitive. Match matches by using the files name with path relative to the file system root with Unix style slashes (/) and no leading slash, e.g. “images/logo.png”. See https://github.com/gobwas/glob for the full rules set.
See the GoDoc Page for the resources package for an up to date overview of all template functions in this namespace.
Get Resource with resources.Get and resources.GetRemote
In order to process an asset with Hugo Pipes, it must be retrieved as a Resource using resources.Get or resources.GetRemote.
With resources.Get, the first argument is a local path relative to the assets directory/directories:
With resources.GetRemote, the first argument is a remote URL:
The return value from resources.GetRemote includes an .Err method that will return an error if the call failed. If you want to just log any error as a WARNING you can use a construct similar to the one below.
Each Hugo Pipes resources transformation method uses a camelCased alias (toCSS for resources.ToCSS).
Non-transformation methods deprived of such aliases are resources.Get, resources.FromString, resources.ExecuteAsTemplate and resources.Concat.
The example above can therefore also be written as follows:
The pipe chain is only invoked the first time it is encountered in a site build, and results are otherwise loaded from cache. As such, Hugo Pipes can be used in templates which are executed thousands or millions of times without negatively impacting the build performance.