# Correct build command for Hugo/Tailwind on CF Pages

**URL:** <https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197>\
**Category:** support\
**Created:** [April 1, 2025, 11:27pm UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197 "2025-04-01T23:27:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tyco](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tyco/32/23754_2.png) [@tyco](https://discourse.gohugo.io/u/tyco)\
**Post date:** [April 1, 2025, 11:27pm UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/1 "2025-04-01T23:27:32Z")

</div>

With [Tailwind v4](https://gohugo.io/functions/css/tailwindcss/#article), and default `hugo` command, the CSS file is not minified in CF Pages even though it is a `.min.css` file. Do I need to add anything to the build command?

---

<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:** [April 2, 2025, 12:06am UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/2 "2025-04-02T00:06:44Z")

</div>

When I follow [these steps](https://gohugo.io/functions/css/tailwindcss/#setup), then run `hugo` (not `hugo server`), my public directory looks like this:

```plaintext
public/
├── css/
│ └── main.eb81ff5e4f0a07045edf9554b7efa00641e43d041b4e514f3795fade5e4b58ba.css
├── posts/
│ ├── post-1/
│ │ └── index.html
│ └── index.html
├── favicon.ico
└── index.html

```

And the CSS file is definitely minified.

---

<div class="post-metadata">

**Author:** ![tyco](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tyco/32/23754_2.png) [@tyco](https://discourse.gohugo.io/u/tyco)\
**Post date:** [April 2, 2025, 12:13am UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/3 "2025-04-02T00:13:22Z")

</div>

I had a [Go Panic](https://discourse.gohugo.io/t/go-panic-with-tailwind-v4/53998) issue with Hugo v0.145.0 and this code was recommended [panic: deferred execution with id "\_\_hdeferred/...=" not found · Issue #13492 · gohugoio/hugo · GitHub](https://github.com/gohugoio/hugo/issues/13492#issuecomment-2734700391). I checked my public folder after running `hugo` and indeed the code for the `.css` is unminified.

---

<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:** [April 2, 2025, 12:28am UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/4 "2025-04-02T00:28:11Z")

</div>

Are you using the `optimize` option instead of the `minify` option? I’d need to see the code.

---

<div class="post-metadata">

**Author:** ![tyco](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tyco/32/23754_2.png) [@tyco](https://discourse.gohugo.io/u/tyco)\
**Post date:** [April 2, 2025, 12:32am UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/5 "2025-04-02T00:32:56Z")

</div>

I just copied that code as it is in the issue comment to the partial and base file.

---

<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:** [April 2, 2025, 12:43am UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/6 "2025-04-02T00:43:29Z")

</div>

Change `optimize` to `minify` and don’t pass the result through the `minify` function.

You shouldn’t have to do this… I’m looking into it.

---

<div class="post-metadata">

**Author:** ![tyco](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tyco/32/23754_2.png) [@tyco](https://discourse.gohugo.io/u/tyco)\
**Post date:** [April 2, 2025, 12:48am UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/7 "2025-04-02T00:48:14Z")

</div>

Thank you. That worked!

---

<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:** [April 2, 2025, 12:58am UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/8 "2025-04-02T00:58:14Z")

</div>

The problem is upstream:  
[https://github.com/tdewolff/minify/issues/651](https://github.com/tdewolff/minify/issues/651)

Setting aside [#13492](https://github.com/gohugoio/hugo/issues/13492), our [documentation](https://gohugo.io/functions/css/tailwindcss/#step-4) is correct:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/b/0/b0f586c2d205dd782971685309f40c7ad0d22d74.png)

But I will update the issue comment.

---

<div class="post-metadata">

**Author:** ![tyco](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tyco/32/23754_2.png) [@tyco](https://discourse.gohugo.io/u/tyco)\
**Post date:** [April 2, 2025, 7:59am UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/9 "2025-04-02T07:59:29Z")

</div>

Noted! What does “optimize” mean in this context?

---

<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:** [April 2, 2025, 12:50pm UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/10 "2025-04-02T12:50:30Z")

</div>

From the Tailwind CLI help:

```plaintext
  -m, --minify ·········· Optimize and minify the output
      --optimize ········ Optimize the output without minifying

```

Our documentation mirrors theirs:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/5/2/52ed887d03002a327ae1b5ca8d18a3cd554ceacc.png)

Neither describes what “optimize” means, and I haven’t found an official explanation anywhere. Let me know if you find one.

[https://github.com/tailwindlabs/tailwindcss/discussions/17507](https://github.com/tailwindlabs/tailwindcss/discussions/17507)

---

<div class="post-metadata">

**Author:** ![tyco](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tyco/32/23754_2.png) [@tyco](https://discourse.gohugo.io/u/tyco)\
**Post date:** [April 2, 2025, 2:11pm UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/11 "2025-04-02T14:11:10Z")

</div>

Interesting! I initially thought optimize is a word encompassing both minify and fingerprint. Let’s here from the TW folks.

---

<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:** [April 4, 2025, 2:11pm UTC](https://discourse.gohugo.io/t/correct-build-command-for-hugo-tailwind-on-cf-pages/54197/12 "2025-04-04T14:11:46Z")

</div>

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