How to purge TailwindCSS

Hello everyone

I am fairly new to Hugo, but I do understand HTML and CSS pretty well.

I guess my issue is a setup issue. I followed this video in order to get TailwindCSS set up with Hugo.

In my head.html file for my custom theme, I have the following:

  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>{{ .Title }}</title>
  <meta name="description" content=" homepage" />

  <meta name="author" content="J Khalaf" />

  <meta property="og:title" content=" homepage" />
  <meta property="og:type" content="website" />
  <meta property="og:url" content="" />
  <meta property="og:description" content=" homepage" />
  <meta property="og:image" content="image.png" />

  <link rel="icon" href="/favicon.ico" />
  <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
  <link rel="apple-touch-icon" href="/apple-touch-icon.png" />

  {{ $styles := resources.Get "css/styles.scss" | toCSS | postCSS (dict "config"
  "./assets/css/postcss.config.js") }} {{ if .Site.IsServer }}
  <link rel="stylesheet" href="{{ $styles.RelPermalink }}" />

  {{ else }} {{ $styles := $styles | minify | fingerprint |
  resources.PostProcess }}

    href="{{ $styles.Permalink }}"
    integrity="{{ $styles.Data.Integrity }}"

  {{ end }}

  <link rel="preconnect" href="" />
  <link rel="preconnect" href="" crossorigin />

There is some “magic” there that I don’t understand. Is the setup above “wrong”? How can I get the purging to work? Right now, the produced CSS when I run hugo -D is 3.2Mb which is massive and I’m only using a few of Tailwind’s classes.

Any help would be greatly appreciated.

You are more likely to receive a prompt and accurate response if you post a link to the public repository for your project.


Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

Here is the repository @jmooring :heart:

1 Like

This project has TailwindCSS with purge set up:

1 Like

404 Page Not Found
Perhaps your repository is private.