Hugo Inline CSS Optimization for Google PageSpeed

With Hugo 0.46 you should be able to use resources for that.

Example of SCSS

{{ with resources.Get "scss/styles.scss" | toCSS | minify }}
<style>{{ .Content | safeCSS }}</style>
{{ end }}

or CSS

{{ with resources.Get "css/styles.css" | minify }}
<style>{{ .Content | safeCSS }}</style>
{{ end }}

Note that resource files needs to be located under /assets directory (not /static)

13 Likes