Hugo Pipes: how to inline generated content from sass pipe

Hi, I’m wondering if there is a way to inline a resource file’s content using the resources pipe (not page Resources, which you can do it with .Content)

In my <head> I’ve got something like this:

{{ $style := resources.Get "scss/style.scss" | resources.ToCSS | resources.Minify }}
<link rel="stylesheet" href="{{ $style.Permalink }}" media="screen" }}">

But rather than link to the generated resource file, I want to inline it directly. My use case is amp styles which need to be inline.

So something like this:

{{ $style := resources.Get "scss/style.scss" | resources.ToCSS | resources.Minify }}
<style amp-custom>{{ $style.Content }}</style>

Which doesn’t seem to work…

I can copy the file into a partial and include it that way, but it means extra build steps which I want avoid if possible

You need to pipe through safeCSS:

{{ $style.Content | safeCSS }}
2 Likes

Ahhh thank you!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.