Issue with css.TailwindCSS

I’m just getting started with Hugo, and I’m in the process of trying to get CSS styling setup using Tailwind. I think I’ve encountered a hugo bug that’s specific to Windows, but ultimately I don’t know what the issue is.

I can link to a repo, but I don’t think it would help. This is more or less a bare repo that follows the directions in the documentation for css.TailwindCSS. Just a site created with hugo new site and then initialized (technically I also created a new theme inside with hugo new theme).

Installing in the base directory using npm, creating the files as directed, and then running hugo build

hugo build --logLevel debug
Start building sites … 
hugo v0.151.1-1cdd17882c28a9f23278d38ef03b403954cfb1e5 windows/amd64 BuildDate=2025-10-15T14:51:34Z VendorInfo=gohugoio

INFO  build:  step process substep collect files 7 files_total 7 pages_total 6 resources_total 1 duration 999.8µs
INFO  build:  step process duration 999.8µs
INFO  build:  step assemble duration 500.2µs
INFO  build:  step render substep pages site en outputFormat html duration 6.5104ms
INFO  build:  step render substep pages site en outputFormat rss duration 999.2µs
INFO  build:  step render pages 18 content 10 duration 8.0086ms
INFO  static: syncing static files to \ duration 17.5092ms
INFO  exec: resolve "tailwindcss" using npx
INFO  tailwindcss: 'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
INFO  build:  step render deferred count 10 duration 25.0638ms
INFO  build:  step postProcess duration 0s
INFO  build:  duration 36.0091ms
Total in 47 ms
Error: error building site: TAILWINDCSS: failed to transform "/css/main.css" (text/css): 'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

It looks to me like Hugo is trying to find tailwindcss in the PATH environment variables, but then running it without quotes? Then erroring out because one of the paths in my PATH environment variable is C:\Program Files...

I’m running Windows 11, Hugo installed via chocolatey.

hugo v0.151.1-1cdd17882c28a9f23278d38ef03b403954cfb1e5 windows/amd64 BuildDate=2025-10-15T14:51:34Z VendorInfo=gohugoio

node v22.20.0
npm 11.6.2

I’d try to switch to hugo in WSL… but then I run into a different issue with it that seems to be a bug in @parcel/watcher and not hugo related.

In the same directory, if I run npx tailwindcss, it will run just fine:

npx tailwindcss
≈ tailwindcss v4.1.14

Usage:
  tailwindcss [--input input.css] [--output output.css] [--watch] [options…]

Options:
  -i, --input ················· Input file
  -o, --output ················ Output file [default: `-`]
  -w, --watch[=always] ········ Watch for changes and rebuild as needed, and use `always` to keep watching when stdin is closed
  -m, --minify ················ Optimize and minify the output
      --optimize ·············· Optimize the output without minifying
      --cwd ··················· The current working directory [default: `.`]
      --map ··················· Generate a source map [default: `false`]
  -h, --help ·················· Display usage information

Any help would be much appreciated.

Does the path to your project directory include a space?

It does have a space in the base directory. I copied it out into a directory with no spaces, and it does seem to work!

However, this certainly begs the question of why that is relevant? If there’s a space in a directory path, I’d love to see the Hugo documentation that suggests it’s not allowed…

And, why that would start to matter now, when I try to add Tailwind to the project rather than any other time? I’m relatively new to Hugo but I have built a site, I just wanted to develop my own theme because the one I started with wasn’t flexible enough for me.

https://github.com/gohugoio/hugo/issues/7333

It’s a messy upstream issue, opened 9 years ago:
https://github.com/golang/go/issues/17149

1 Like

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