# Embed generated CSS in HTML

**URL:** <https://discourse.gohugo.io/t/embed-generated-css-in-html/47350>\
**Category:** support\
**Created:** [December 5, 2023, 5:15pm UTC](https://discourse.gohugo.io/t/embed-generated-css-in-html/47350 "2023-12-05T17:15:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![attractmore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/attractmore/32/20816_2.png) [@attractmore](https://discourse.gohugo.io/u/attractmore)\
**Post date:** [December 5, 2023, 5:15pm UTC](https://discourse.gohugo.io/t/embed-generated-css-in-html/47350/1 "2023-12-05T17:15:50Z")

</div>

I’m using SCSS and having HUGO generate the CSS which works fine and I can set up a link to the generated stylesheet, no problem. However, I’d like to embed the contents of that CSS file into the HTML and I can’t find a way of doing that. Is it possible?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [December 5, 2023, 5:19pm UTC](https://discourse.gohugo.io/t/embed-generated-css-in-html/47350/2 "2023-12-05T17:19:38Z")

</div>

[https://gohugo.io/methods/resource/content/](https://gohugo.io/methods/resource/content/)

Search the page for “To create inline CSS”

---

<div class="post-metadata">

**Author:** ![chrillek](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/chrillek/32/19797_2.png) [@chrillek](https://discourse.gohugo.io/u/chrillek)\
**Post date:** [December 5, 2023, 5:19pm UTC](https://discourse.gohugo.io/t/embed-generated-css-in-html/47350/3 "2023-12-05T17:19:39Z")

</div>

Perhaps by using `.Content` instead of `.Permalink`. Without seeing your code, difficult to say.

---

<div class="post-metadata">

**Author:** ![attractmore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/attractmore/32/20816_2.png) [@attractmore](https://discourse.gohugo.io/u/attractmore)\
**Post date:** [December 5, 2023, 5:42pm UTC](https://discourse.gohugo.io/t/embed-generated-css-in-html/47350/4 "2023-12-05T17:42:03Z")

</div>

Thanks for your quick replies

I tried this

```auto
{{- $opts := dict "transpiler" "libsass" "targetPath" "css/style.css" "outputStyle" "compressed" }}
{{- with resources.Get "/scss/critical.scss" | toCSS $opts }}
{{- end -}}

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

```

but no style tag is generated so there’s something I’m not understanding here!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [December 5, 2023, 5:57pm UTC](https://discourse.gohugo.io/t/embed-generated-css-in-html/47350/5 "2023-12-05T17:57:17Z")

</div>

```plaintext
{{- with resources.Get "/scss/critical.scss" | toCSS $opts }}
  <style>{{ .Content | safeCSS }}</style>
{{- end -}}

```

---

<div class="post-metadata">

**Author:** ![attractmore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/attractmore/32/20816_2.png) [@attractmore](https://discourse.gohugo.io/u/attractmore)\
**Post date:** [December 5, 2023, 5:59pm UTC](https://discourse.gohugo.io/t/embed-generated-css-in-html/47350/6 "2023-12-05T17:59:22Z")

</div>

That’s it. Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [December 7, 2023, 5:59pm UTC](https://discourse.gohugo.io/t/embed-generated-css-in-html/47350/7 "2023-12-07T17:59:47Z")

</div>

Closed on December 7, 2023, 5:59pm UTC

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