# Adding Tailwindcss

**URL:** <https://discourse.gohugo.io/t/adding-tailwindcss/24001>\
**Category:** support\
**Created:** [March 14, 2020, 9:24am UTC](https://discourse.gohugo.io/t/adding-tailwindcss/24001 "2020-03-14T09:24:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![trace751](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@trace751](https://discourse.gohugo.io/u/trace751)\
**Post date:** [March 14, 2020, 9:24am UTC](https://discourse.gohugo.io/t/adding-tailwindcss/24001/1 "2020-03-14T09:24:04Z")

</div>

I would like to use the Tailwindcss framework with my Hug project. I’m not sure how to add this in rather than using their CDN. How can I add this to my project the right way?

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 14, 2020, 11:06am UTC](https://discourse.gohugo.io/t/adding-tailwindcss/24001/2 "2020-03-14T11:06:59Z")

</div>

Hey,

Once I get some free time I will create a GitHub Tailwind starter template. But my current recommended setup would be to install Tailwind and the other PostCSS plugins you want to use via NPM and then do something like this in your header template:

```auto
    {{ $options := dict "inlineImports" true }}
    {{ $isProd := eq hugo.Environment "production"}}
    {{ $styles := resources.Get "css/styles.css" }}
    {{ $styles = $styles | resources.PostCSS $options }}
    {{ if $isProd }}
    {{ $styles = $styles | minify | fingerprint }}
    {{ end }}
    <link href="{{ $styles.RelPermalink }}" rel="stylesheet" />

```

Then put your css below /assets/css, e.g.:

```css
@tailwind base;

@tailwind components;
@tailwind utilities;

@import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,700,700i&display=swap');

@import "components/all.css";

html {
  font-size: 14px;
}

```

Note that this:

```auto
    {{ $options := dict "inlineImports" true }}

```

Which enables native inline CSS import in Hugo requires a fairly recent Hugo version.

---

<div class="post-metadata">

**Author:** ![trace751](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@trace751](https://discourse.gohugo.io/u/trace751)\
**Post date:** [March 14, 2020, 11:19pm UTC](https://discourse.gohugo.io/t/adding-tailwindcss/24001/3 "2020-03-14T23:19:45Z")

</div>

Hi thank you for helping. I am getting an error when trying to push to local server. I have my postcss.config.js in my root directory and my styles.css in assets/css. I included the code you provided in my partials/head.html. Please see the error I receive. I tried fixing it but not sure what I’m doing wrong I’m on my third day learning Hugo.

```auto
render of "home" failed: execute of template failed: template: index.html:1:3: executing "index.html" at <partial "head" .>: error calling partial: "C:\Users\Ram\Documents\hugo\13\layouts\partials\head.html:17:36": execute of template failed: template: partials/head.html:17:36: executing "partials/head.html" at <resources.PostCSS>: error calling PostCSS: no Resource provided in transformation
render of "page" failed: execute of template failed: template: _default/single.html:1:3: executing "_default/single.html" at <partial "head" .>: error calling partial: "C:\Users\Ram\Documents\hugo\13\layouts\partials\head.html:17:36": execute of template failed: template: partials/head.html:17:36: executing "partials/head.html" at <resources.PostCSS>: error calling PostCSS: no Resource provided in transformation
Rebuild failed:

Failed to render pages: render of "page" failed: execute of template failed: template: _default/single.html:1:3: executing "_default/single.html" at <partial "head" .>: error calling partial: "C:\Users\Ram\Documents\hugo\13\layouts\partials\head.html:17:36": execute of template failed: template: partials/head.html:17:36: executing "partials/head.html" at <resources.PostCSS>: error calling PostCSS: no Resource provided in transformation

```

---

<div class="post-metadata">

**Author:** ![divinerites](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/divinerites/32/12625_2.png) [@divinerites](https://discourse.gohugo.io/u/divinerites)\
**Post date:** [March 15, 2020, 12:38am UTC](https://discourse.gohugo.io/t/adding-tailwindcss/24001/4 "2020-03-15T00:38:10Z")

</div>

> [@bep](#):
>
> put your css below /assets/css, e.g

Did you put your `styles.css` inside ` /assets/css/` ??  
Message _seems_ to indicate it is not there.

---

<div class="post-metadata">

**Author:** ![trace751](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@trace751](https://discourse.gohugo.io/u/trace751)\
**Post date:** [March 15, 2020, 2:03am UTC](https://discourse.gohugo.io/t/adding-tailwindcss/24001/5 "2020-03-15T02:03:28Z")

</div>

@bep @divinerites  
Yes I even tried moving the assets to different parts of the directory. I made a fresh Hugo directory to test it out and I get the error:

```auto
Failed to render pages: render of "home" failed: "C:\Users\Ram\Documents\newhugotest\testpostcss\layouts\index.html:10:36": execute of template failed: template: index.html:10:36: executing "index.html" at <resources.PostCSS>: error calling PostCSS: no Resource provided in transformation

```

The new test repo is [https://github.com/hungryram/tailwindtest.git](https://github.com/hungryram/tailwindtest.git) if you’d like to check it out. I’ve been trying all day 😕

---

<div class="post-metadata">

**Author:** ![divinerites](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/divinerites/32/12625_2.png) [@divinerites](https://discourse.gohugo.io/u/divinerites)\
**Post date:** [March 15, 2020, 7:01am UTC](https://discourse.gohugo.io/t/adding-tailwindcss/24001/6 "2020-03-15T07:01:32Z")

</div>

> [@trace751](#):
>
> The new test repo is [https://github.com/hungryram/tailwindtest.git](https://github.com/hungryram/tailwindtest.git) if you’d like to check it out.

Where is your hugo code ?

[EDIT] : ah I see, but it seems that you do not have a **proper hugo** structure folders.  
**At least** you have to create a `/assets/css/` folder and put your `styles.css` inside.

> **[hugo new site](https://gohugo.io/commands/hugo_new_site/)**
>
> hugo new site Create a new site (skeleton)
> Synopsis Create a new site in the provided directory. The new site will have the correct structure, but no content or theme yet. Use hugo new \[contentPath\] to create new content.
> hugo new site \[path\] \[flags\]...

> **[Hugo Pipes](https://gohugo.io/hugo-pipes/introduction/#asset-directory)**
>
> Hugo Pipes is Hugo's asset processing set of functions.

---

<div class="post-metadata">

**Author:** ![trace751](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@trace751](https://discourse.gohugo.io/u/trace751)\
**Post date:** [March 15, 2020, 7:12am UTC](https://discourse.gohugo.io/t/adding-tailwindcss/24001/7 "2020-03-15T07:12:57Z")

</div>

I was able to figure it out without using PostCSS. Currently creating a boilerplate for myself so I could just build off of it with Netlify CMS.

---

<div class="post-metadata">

**Author:** ![divinerites](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/divinerites/32/12625_2.png) [@divinerites](https://discourse.gohugo.io/u/divinerites)\
**Post date:** [March 15, 2020, 7:15am UTC](https://discourse.gohugo.io/t/adding-tailwindcss/24001/8 "2020-03-15T07:15:10Z")

</div>

> [@divinerites](#):
>
> Did you put your `styles.css` inside ` /assets/css/`

But you didn’t follow our advices. that is the reason of your error message.

---

<div class="post-metadata">

**Author:** ![trace751](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@trace751](https://discourse.gohugo.io/u/trace751)\
**Post date:** [March 15, 2020, 7:27am UTC](https://discourse.gohugo.io/t/adding-tailwindcss/24001/9 "2020-03-15T07:27:21Z")

</div>

Hi, yes I did that but I kept getting a PostCSS error. Kind of gave up due to frustration and went a different route I followed the installation of Brads video: [https://www.youtube.com/watch?v=UBOj6rqRUME&t=342s](https://www.youtube.com/watch?v=UBOj6rqRUME&t=342s)

Changed some of the filing structure and currently building a boilerplate here where you can see the repo here: [https://github.com/hungryram/hugo-boilerplate.git](https://github.com/hungryram/hugo-boilerplate.git)

Let me know what you think. Still a few days into Hugo, I like it so far, definitely prefer it over Gatsby for a smaller site.

---

<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:** [March 17, 2020, 7:27am UTC](https://discourse.gohugo.io/t/adding-tailwindcss/24001/10 "2020-03-17T07:27:31Z")

</div>

Closed on March 17, 2020, 7:27am UTC

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