dirkolbrich / hugo-tailwindcss-starter-theme

Starter files for a Hugo theme with Tailwindcss
MIT License
398 stars 55 forks source link

Succeeding Netlify Production Build Causes Error... #16

Closed codeitlikemiley closed 4 years ago

codeitlikemiley commented 4 years ago

Hi, Im facing a problem where The First Build Works like charm...

But any succeeding build would cause error

The error is cause by css/css/style.css_STRING file not found in file cache

I need to Manually Deploy the Site by clicking "Clear Cache and Deploy Site" inside netlify...

Any solution to this?

my netlify.toml file looks like this...

[build]
  publish = "exampleSite/public"
  command = "cd exampleSite && hugo --gc --minify --themesDir ../.. -b $HUGO_BASEURL"

[build.environment]
  HUGO_VERSION = "0.70.0"
  HUGO_BASEURL = "https://another-hugo-starter-theme.netlify.app"
  HUGO_THEME = "repo"
  HUGO_ENV = "production"
  HUGO_ENABLEGITINFO = "true"

[context.split1]
  command = "cd exampleSite && hugo --gc --minify --themesDir ../.. -b $HUGO_BASEURL --enableGitInfo"

[context.split1.environment]
  HUGO_VERSION = "0.70.0"
  HUGO_ENV = "production"

[context.deploy-preview]
  command = "cd exampleSite && hugo --gc --minify --themesDir ../.. -b $HUGO_BASEURL --buildFuture"

[context.deploy-preview.environment]
  HUGO_VERSION = "0.70.0"

[context.branch-deploy]
  command = "cd exampleSite && hugo --gc --minify --themesDir ../.. -b $DEPLOY_PRIME_URL"

[context.branch-deploy.environment]
  HUGO_VERSION = "0.70.0"

[context.next.environment]
  HUGO_ENABLEGITINFO = "true"

error is like this


6:57:44 PM: Build ready to start
6:57:46 PM: build-image version: 6dfe19d15f524c85d6f9bf7df9fb30b0a9f0a61a
6:57:46 PM: build-image tag: v3.3.10
6:57:46 PM: buildbot version: 6bb3f784302b4ad90de13035b247a363a8bee34a
6:57:46 PM: Fetching cached dependencies
6:57:46 PM: Starting to download cache of 109.4MB
6:57:47 PM: Finished downloading cache in 586.323103ms
6:57:47 PM: Starting to extract cache
6:57:51 PM: Finished extracting cache in 4.251460153s
6:57:51 PM: Finished fetching cache in 4.86821134s
6:57:51 PM: Starting to prepare the repo for build
6:57:51 PM: Preparing Git Reference refs/heads/master
6:57:52 PM: Found Netlify configuration file netlify.toml in site root
6:57:52 PM: Found Netlify configuration file(s). Overriding site configuration
6:57:52 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'cd exampleSite && hugo --gc --minify --themesDir ../.. -b $HUGO_BASEURL' versus 'cd exampleSite && hugo --gc --themesDir ../..' in the Netlify UI
6:57:52 PM: Starting build script
6:57:52 PM: Installing dependencies
6:57:52 PM: Started restoring cached node version
6:57:56 PM: Finished restoring cached node version
6:57:57 PM: v10.20.1 is already installed.
6:57:58 PM: Now using node v10.20.1 (npm v6.14.4)
6:57:58 PM: Attempting ruby version 2.6.2, read from environment
6:57:59 PM: Using ruby version 2.6.2
6:58:00 PM: Using PHP version 5.6
6:58:00 PM: 5.2 is already installed.
6:58:00 PM: Using Swift version 5.2
6:58:00 PM: Started restoring cached node modules
6:58:00 PM: Finished restoring cached node modules
6:58:00 PM: Installing Hugo 0.70.0
6:58:00 PM: Hugo Static Site Generator v0.70.0-7F47B99E/extended linux/amd64 BuildDate: 2020-05-06T11:26:13Z
6:58:00 PM: Started restoring cached go cache
6:58:00 PM: Finished restoring cached go cache
6:58:00 PM: go version go1.12 linux/amd64
6:58:00 PM: go version go1.12 linux/amd64
6:58:00 PM: Installing missing commands
6:58:00 PM: Verify run directory
6:58:00 PM: Executing user command: cd exampleSite && hugo --gc --minify --themesDir ../.. -b $HUGO_BASEURL
6:58:00 PM: Building sites …
6:58:00 PM: Total in 102 ms
6:58:00 PM: Error: Error building site: POSTCSS: failed to transform "css/styles.css" (text/css): resource "css/css/styles.css_f2054ba793222939610cd2936fa9ba1e" not found in file cache
6:58:00 PM: Skipping functions preparation step: no functions directory set
6:58:00 PM: Caching artifacts
6:58:00 PM: Started saving pip cache
6:58:00 PM: Finished saving pip cache
6:58:00 PM: Started saving emacs cask dependencies
6:58:00 PM: Finished saving emacs cask dependencies
6:58:00 PM: Started saving maven dependencies
6:58:00 PM: Finished saving maven dependencies
6:58:00 PM: Started saving boot dependencies
6:58:01 PM: Finished saving boot dependencies
6:58:01 PM: Started saving go dependencies
6:58:01 PM: Finished saving go dependencies
6:58:01 PM: Error running command: Build script returned non-zero exit code: 255
6:58:01 PM: Failing build: Failed to build site
6:58:01 PM: Failed during stage 'building site': Build script returned non-zero exit code: 255
6:58:01 PM: Finished processing build request in 15.142736701s
dirkolbrich commented 4 years ago

I suppose, you have a standard Hugo directory structure, where the themes folder is directly under the projects root, like so your-project/themes/your-theme. And you run the hugo build command from the projects root.

Try to remove --themesDir ../.. from your build commands. This flag has the purpose to point the hugo build process to the themes directory if your want to use any other than the default directory structure.

dirkolbrich commented 4 years ago

I just saw that you jump into the /exampleSite folder as the first step of your build command. Why?

codeitlikemiley commented 4 years ago

Hi Dirkolbrich I dont add a new Hugo site.. Like the norms where u do Hugo new site mysite... Where u would add your theme in the theme mysite/themes

What I did was i use the current theme As it is and use exampleSite as the Hugo site... Thats why I have it set up like that...

How are u doing ur set up for netlify? My folder structure is as is as u would clone this repo. I have no Hugo root folder where u normally house the themes

On Tue, 12 May 2020, 20:21 Dirk Olbrich, notifications@github.com wrote:

I just saw that you jump into the /exampleSite folder as the first step of your build command. Why?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dirkolbrich/hugo-theme-tailwindcss-starter/issues/16#issuecomment-627308286, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG33KMXBMTMNXXYAZ7QHDM3RRE5N3ANCNFSM4M6X43PQ .

dirkolbrich commented 4 years ago

OK, I see.

First try and change you build script to:

[build]
  publish = "public"
  command = "hugo -s exampleSite --gc --minify --themesDir ../.. -b $HUGO_BASEURL"

And change all other commands to use -s exampleSite instead of cd into a subfolder.

Second: this theme starter repo is not intended to be deployed as a separate project with the content residing in a subfolder. It is intended to function as a boilerplate to develop a separate theme. This theme should be located under the /themes folder within a standard Hugo project.

dirkolbrich commented 4 years ago

Wait, let the first row as it was:

[build]
  publish = "exampleSite/public"
goldcoders commented 4 years ago

the first one

[build]
  publish = "public"
  command = "hugo -s exampleSite --gc --minify --themesDir ../.. -b $HUGO_BASEURL"

the error is public directory does not exist

8:53:53 PM: Building sites …
8:54:00 PM:                   | EN
8:54:00 PM: -------------------+-----
8:54:00 PM:   Pages            | 26
8:54:00 PM:   Paginator pages  |  0
8:54:00 PM:   Non-page files   |  0
8:54:00 PM:   Static files     |  9
8:54:00 PM:   Processed images |  0
8:54:00 PM:   Aliases          |  0
8:54:00 PM:   Sitemaps         |  1
8:54:00 PM:   Cleaned          |  0
8:54:00 PM: Total in 7109 ms
8:54:00 PM: Skipping functions preparation step: no functions directory set
8:54:00 PM: Caching artifacts
8:54:00 PM: Started saving node modules
8:54:00 PM: Finished saving node modules
8:54:00 PM: Started saving pip cache
8:54:00 PM: Finished saving pip cache
8:54:00 PM: Started saving emacs cask dependencies
8:54:00 PM: Finished saving emacs cask dependencies
8:54:00 PM: Started saving maven dependencies
8:54:00 PM: Finished saving maven dependencies
8:54:00 PM: Started saving boot dependencies
8:54:00 PM: Finished saving boot dependencies
8:54:00 PM: Started saving go dependencies
8:54:00 PM: Finished saving go dependencies
8:54:05 PM: Build script success
8:54:05 PM: Failing build: Failed to build site
8:54:05 PM: Failed during stage 'building site': Deploy directory 'public' does not exist

the second one

[build]
  publish = "exampleSite/public"

The same Error: Error building site: POSTCSS: failed to transform "css/styles.css" (text/css): resource "css/css/styles.css_f2054ba793222939610cd2936fa9ba1e" not found in file cache

8:56:22 PM: Build ready to start
8:56:24 PM: build-image version: 6dfe19d15f524c85d6f9bf7df9fb30b0a9f0a61a
8:56:24 PM: build-image tag: v3.3.10
8:56:24 PM: buildbot version: 6bb3f784302b4ad90de13035b247a363a8bee34a
8:56:25 PM: Fetching cached dependencies
8:56:25 PM: Starting to download cache of 109.4MB
8:56:26 PM: Finished downloading cache in 1.900380047s
8:56:26 PM: Starting to extract cache
8:56:31 PM: Finished extracting cache in 4.313452141s
8:56:31 PM: Finished fetching cache in 6.252733182s
8:56:31 PM: Starting to prepare the repo for build
8:56:31 PM: Preparing Git Reference refs/heads/master
8:56:32 PM: Found Netlify configuration file netlify.toml in site root
8:56:32 PM: Found Netlify configuration file(s). Overriding site configuration
8:56:32 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'hugo -s exampleSite --gc --minify --themesDir ../.. -b $HUGO_BASEURL' versus 'cd exampleSite && hugo --gc --themesDir ../..' in the Netlify UI
8:56:32 PM: Starting build script
8:56:32 PM: Installing dependencies
8:56:33 PM: Started restoring cached node version
8:56:37 PM: Finished restoring cached node version
8:56:37 PM: v10.20.1 is already installed.
8:56:38 PM: Now using node v10.20.1 (npm v6.14.4)
8:56:38 PM: Attempting ruby version 2.6.2, read from environment
8:56:40 PM: Using ruby version 2.6.2
8:56:40 PM: Using PHP version 5.6
8:56:40 PM: 5.2 is already installed.
8:56:41 PM: Using Swift version 5.2
8:56:41 PM: Started restoring cached node modules
8:56:41 PM: Finished restoring cached node modules
8:56:42 PM: Installing Hugo 0.69.0
8:56:42 PM: Hugo Static Site Generator v0.69.0-4205844B/extended linux/amd64 BuildDate: 2020-04-10T09:16:58Z
8:56:42 PM: Started restoring cached go cache
8:56:42 PM: Finished restoring cached go cache
8:56:42 PM: go version go1.12 linux/amd64
8:56:42 PM: go version go1.12 linux/amd64
8:56:42 PM: Installing missing commands
8:56:42 PM: Verify run directory
8:56:42 PM: Executing user command: hugo -s exampleSite --gc --minify --themesDir ../.. -b $HUGO_BASEURL
8:56:42 PM: Building sites …
8:56:42 PM: Total in 125 ms
8:56:42 PM: Error: Error building site: POSTCSS: failed to transform "css/styles.css" (text/css): resource "css/css/styles.css_f2054ba793222939610cd2936fa9ba1e" not found in file cache
8:56:42 PM: Skipping functions preparation step: no functions directory set
8:56:42 PM: Caching artifacts
8:56:42 PM: Started saving node modules
8:56:42 PM: Finished saving node modules
8:56:42 PM: Started saving pip cache
8:56:42 PM: Finished saving pip cache
8:56:42 PM: Started saving emacs cask dependencies
8:56:42 PM: Finished saving emacs cask dependencies
8:56:42 PM: Started saving maven dependencies
8:56:42 PM: Finished saving maven dependencies
8:56:42 PM: Started saving boot dependencies
8:56:42 PM: Finished saving boot dependencies
8:56:42 PM: Started saving go dependencies
8:56:42 PM: Finished saving go dependencies
8:56:42 PM: Error running command: Build script returned non-zero exit code: 255
8:56:42 PM: Failing build: Failed to build site
8:56:42 PM: Failed during stage 'building site': Build script returned non-zero exit code: 255
8:56:42 PM: Finished processing build request in 18.473365458s
goldcoders commented 4 years ago

the second one i think is correct , its like the old script i have with cd exampleSite... they produced the same exact error...

dirkolbrich commented 4 years ago

Please post your folder structure and add the -v verbose flag to the build command.

There seems to be somehow a duplication of the css folder structure:

POSTCSS: failed to transform "css/styles.css" (text/css): resource "css/css/styles.css_f2054ba793222939610cd2936fa9ba1e"

goldcoders commented 4 years ago

this is the folder structure

drwxr-xr-x    - uriah 12 May 21:00 .git 
drwxr-xr-x    - uriah  6 May  9:22 archetypes 
drwxr-xr-x    - uriah  6 May  9:22 assets 
drwxr-xr-x    - uriah 12 May 19:59 exampleSite 
drwxr-xr-x    - uriah 12 May 15:05 layouts 
drwxr-xr-x    - uriah  9 May 18:15 node_modules 
.rw-r--r--   22 uriah 12 May 19:52 .gitignore 
.rw-r--r-- 1.1k uriah  6 May  9:26 LICENSE 
.rw-r--r-- 4.6k uriah 12 May 14:59 markdown-example.md 
.rw-r--r--  939 uriah 12 May 21:00 netlify.toml 
.rw-r--r--  58k uriah  6 May  9:37 package-lock.json 
.rw-r--r--  799 uriah  6 May  9:37 package.json 
.rw-r--r-- 6.6k uriah  6 May  9:26 readme.md 
.rw-r--r--  497 uriah 12 May 17:26 theme.toml 

inside exampleSite

drwxr-xr-x    - uriah  7 May 16:00 content 
drwxr-xr-x    - uriah 11 May  6:13 data 
drwxr-xr-x    - uriah 12 May 21:01 public 
drwxr-xr-x    - uriah  7 May 15:41 resources 
drwxr-xr-x    - uriah 11 May  5:38 static 
.rw-r--r--   14 uriah  7 May 16:14 .gitignore 
.rw-r--r-- 1.2k uriah 12 May 18:24 config.toml 
.rw-r--r--  316 uriah 11 May  3:36 nestead_menu.txt                                                                              
dirkolbrich commented 4 years ago

I think your folder structure and from where you run the build script messes somehow with the path finding process of PostCSS. But I don't know why.

The first example with

[build]
  publish = "public"
  command = "hugo -s exampleSite --gc --minify --themesDir ../.. -b $HUGO_BASEURL"

finishes the build process, as indicated by 8:54:05 PM: Build script success but hangs on finding the public folder. As you would expect, since the /public folder is build under /exampleSite, like it would on a local dev machine.

The second example with publish = "exampleSite/public" fails directly with the build script as indicated by 8:56:42 PM: Failed during stage 'building site': Build script returned non-zero exit code: 255.

goldcoders commented 4 years ago

I manage to Fixed This Issue.

This issue is happening because resources/ is in the .gitignore when ive push commit , there is no folder that html script is referencing those files that are generated

.rw-r--r-- 4.0M uriah 13 May 21:54 styles.css_2470d520f8390e01a1a99d32c19f09b5.content 
.rw-r--r--   60 uriah 13 May 21:54 styles.css_2470d520f8390e01a1a99d32c19f09b5.json 
.rw-r--r--  22k uriah 12 May 23:25 styles.css_f2054ba793222939610cd2936fa9ba1e.content 
.rw-r--r--  194 uriah 12 May 23:25 styles.css_f2054ba793222939610cd2936fa9ba1e.json 

As Ive read the head.html the resource.PostProcess actually ends up that value in that folder.


{{ $styles := resources.Get "css/styles.css" | postCSS (dict "config" "./assets/css/postcss.config.js") }}
{{ if .Site.IsServer }}
    <link rel="stylesheet" href="{{ $styles.RelPermalink }}">
{{ else }}
    {{ $styles := $styles| minify | fingerprint | resources.PostProcess }}
    <link rel="stylesheet" href="{{ $styles.Permalink }}" integrity="{{ $styles.Data.Integrity }}">
{{ end }}

I hope you update the documentation , to include the following...

Min Version of HUGO 0.69.0 Also A .Netlily or Netlify.toml Lastly a .gitignore file

All of the error arises from this 3 things...

dirkolbrich commented 4 years ago

Cool, thanks for your feedback. I will add a min version and a .gitignorefile in the next update round.

But I will NOT add a .netlify or netlify.toml file, as this is a direct implementation dependency. Some people might (including me) not use this service. And I don't have the time or even the knowledge to maintain this file. As stated above, this belongs into the main Hugo project directory, not into this theme directory.

You should not deploy this theme as a standalone project outside of a Hugo site to Netlify. This is a theme package, it belongs into the /themes folder of a Hugo project.