HUGO
Menu
GitHub 90597 stars Mastodon

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.

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 }}