resources.Minify
Returns a minified version of the given resource.
- Syntax
- resources.Minify RESOURCE
- Returns
- resource.Resource
- Alias
- minify
Usage
The resources.Minify function returns a minified version of the given resource. The resource must be a CSS, JavaScript, JSON, HTML, SVG, or XML file. Otherwise, Hugo returns an error when you access the content or URL of the returned resource.
This works with global resources, page resources, and remote resources.
Hugo uses the tdewolff/minify package to minify the resource. To change the minifier settings, or to disable minification for a specific file type, configure minify.
Examples
{{ with resources.Get "css/main.css" }}
{{ with resources.Minify . }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ end }}
{{ end }}Last updated:
November 24, 2026
:
content: Apply style guide to resources functions (1dbb46409)
Improve this page