dirkolbrich / hugo-tailwindcss-starter-theme

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

hugo --gc --minify not generating index.html #10

Closed rockey5520 closed 4 years ago

rockey5520 commented 4 years ago

I followed your instructions, and able to start server using hugo server --disableFastRender but when i run hugo --gc --minify index.html is not generated in public folder. would you be able to suggest the right command

dirkolbrich commented 4 years ago

Hi, sorry I can not reproduce your error. These are the exact steps I tested:

➜  gohugo$ hugo new site test-minify
➜  gohugo$ cd test-minify/themes
➜  themes$ git clone https://github.com/dirkolbrich/hugo-theme-tailwindcss-starter minify-tailwind
➜  themes$ cd minify-tailwind 
➜  minify-tailwind git:(master)$ rm -rf .git
➜  minify-tailwind$ npm install
➜  minify-tailwind$ npm audit fix //not necessary, but always good to audit your npm packages
➜  minify-tailwind$ cd ..
➜  themes$ cd ..                     
// here I added theme = "minify-tailwind" to /test-minify/config.toml
➜  test-minify$ hugo server --disableFastRender                                                                                                                                   
➜  test-minify$ hugo --gc --minify

Here is the corresponding complete output to these commands:

➜  gohugo$ hugo new site test-minify
Congratulations! Your new Hugo site is created in /Users/dirkolbrich/Coding/gohugo/test-minify.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/ or
   create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".

Visit https://gohugo.io/ for quickstart guide and full documentation.
➜  gohugo$ cd test-minify/themes
➜  themes$ git clone https://github.com/dirkolbrich/hugo-theme-tailwindcss-starter minify-tailwind
Klone nach 'minify-tailwind' ...
remote: Enumerating objects: 66, done.
remote: Counting objects: 100% (66/66), done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 258 (delta 25), reused 47 (delta 15), pack-reused 192
Empfange Objekte: 100% (258/258), 190.56 KiB | 527.00 KiB/s, Fertig.
Löse Unterschiede auf: 100% (100/100), Fertig.
➜  themes$ cd minify-tailwind 
➜  minify-tailwind git:(master)$ rm -rf .git
➜  minify-tailwind$ npm install
added 168 packages from 183 contributors and audited 410 packages in 2.837s

7 packages are looking for funding
  run `npm fund` for details

found 1 moderate severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details
➜  minify-tailwind$ npm audit fix
updated 1 package in 0.877s

7 packages are looking for funding
  run `npm fund` for details

fixed 1 of 1 vulnerability in 410 scanned packages
➜  minify-tailwind$ cd ..
➜  themes$ cd ..                          
➜  test-minify$ hugo server --disableFastRender

                   | EN  
-------------------+-----
  Pages            |  7  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     |  0  
  Processed images |  0  
  Aliases          |  0  
  Sitemaps         |  1  
  Cleaned          |  0  

Built in 2480 ms
Watching for changes in /Users/dirkolbrich/Coding/gohugo/test-minify/{archetypes,content,data,layouts,static,themes}
Watching for config changes in /Users/dirkolbrich/Coding/gohugo/test-minify/config.toml
Environment: "development"
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
^C%                                                                                                                                      
➜  test-minify$ hugo --gc --minify

                   | EN  
-------------------+-----
  Pages            |  7  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     |  0  
  Processed images |  0  
  Aliases          |  0  
  Sitemaps         |  1  
  Cleaned          |  2  

Total in 2658 ms
➜  test-minify$

After that I have a /public folder under /test-minify with a minified index.html, just as it is supposed to be.

Please describe your exact steps within the cli and use the --verbose flag. Maybe this gives a hint of the error.

rockey5520 commented 4 years ago

Hello Dirk Olbrich I appreciate your swift response. After following your above-given steps I am able to see content under the public folder I must have made some silly mistake before. One more question after performing the above-mentioned steps I am able to see content inside public folder however when I open index.html it displays content without any CSS styling. I have laid out the steps I followed with --verbose flag. would you be able to correct me if possible?

image

`PS C:\Users\Rockey\VSCodeProjects> hugo new site --verbose test-minify Congratulations! Your new Hugo site is created in C:\Users\Rockey\VSCodeProjects\test-minify.

Just a few more steps and you're ready to go:

  1. Download a theme into the same-named folder. Choose a theme from https://themes.gohugo.io/ or create your own with the "hugo new theme " command.
  2. Perhaps you want to add some content. You can add single files with "hugo new \.".
  3. Start the built-in live server via "hugo server".

Visit https://gohugo.io/ for quickstart guide and full documentation.`

`PS C:\Users\Rockey\VSCodeProjects> cd test-minify/themes
PS C:\Users\Rockey\VSCodeProjects\test-minify\themes> git clone https://github.com/dirkolbrich/hugo-theme-tailwindcss-starter minify-tailwind
Cloning into 'minify-tailwind'...
remote: Enumerating objects: 74, done.
remote: Counting objects: 100% (74/74), done.
remote: Compressing objects: 100% (55/55), done.

Receiving objects: 100% (266/266), 191.79 KiB | 967.00 KiB/s, done.
Resolving deltas: 100% (105/105), done.
PS C:\Users\Rockey\VSCodeProjects\test-minify\themes> cd minify-tailwind`
`PS C:\Users\Rockey\VSCodeProjects\test-minify\themes\minify-tailwind> npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 166 packages from 179 contributors and audited 410 packages in 4.488s

7 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

PS C:\Users\Rockey\VSCodeProjects\test-minify\themes\minify-tailwind> cd ..
PS C:\Users\Rockey\VSCodeProjects\test-minify\themes> cd ..`

// I added theme = "minify-tailwind" to /test-minify/config.toml

`PS C:\Users\Rockey\VSCodeProjects\test-minify> hugo server --disableFastRender --verbose
INFO 2020/03/12 07:36:49 No translation bundle found for default language "en"
INFO 2020/03/12 07:36:49 Translation func for language en not found, use default.
INFO 2020/03/12 07:36:49 i18n not initialized; if you need string translations, check that you have a bundle in /i18n that matches the site language or the default language.
INFO 2020/03/12 07:36:49 Using config file:
Building sites … INFO 2020/03/12 07:36:49 syncing static files to C:\Users\Rockey\VSCodeProjects\test-minify\
INFO 2020/03/12 07:36:49 postcss: use config file C:\Users\Rockey\VSCodeProjects\test-minify\themes\minify-tailwind\assets\css\dev\postcss.config.js

                   | EN
-------------------+-----
  Pages            |  7
  Paginator pages  |  0
  Non-page files   |  0
  Static files     |  0
  Processed images |  0
  Aliases          |  0
  Sitemaps         |  1
  Cleaned          |  0

Built in 3103 ms
Watching for changes in C:\Users\Rockey\VSCodeProjects\test-minify\{archetypes,content,data,layouts,static,themes}
Watching for config changes in C:\Users\Rockey\VSCodeProjects\test-minify\config.toml
Environment: "development"
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop`

// localhost:1313 image

`PS C:\Users\Rockey\VSCodeProjects\test-minify> hugo --gc --minify --verbose
INFO 2020/03/12 07:38:12 No translation bundle found for default language "en"
INFO 2020/03/12 07:38:12 Translation func for language en not found, use default.
INFO 2020/03/12 07:38:12 i18n not initialized; if you need string translations, check that you have a bundle in /i18n that matches the site language or the default language.
INFO 2020/03/12 07:38:12 Using config file:
Building sites … INFO 2020/03/12 07:38:12 syncing static files to C:\Users\Rockey\VSCodeProjects\test-minify\public\
INFO 2020/03/12 07:38:12 postcss: use config file C:\Users\Rockey\VSCodeProjects\test-minify\themes\minify-tailwind\assets\css\postcss.config.js

                   | EN
-------------------+-----
  Pages            |  7
  Paginator pages  |  0
  Non-page files   |  0
  Static files     |  0
  Processed images |  0
  Aliases          |  0
  Sitemaps         |  1
  Cleaned          |  2

Total in 3041 ms`

// public folder image // when opened index.html image

I hope the provided information is enough to suggest the mistake here. Please feel free to let me know if you require more information.

dirkolbrich commented 4 years ago

If you open the website locally, your browser does not find the styles.css file. Check your index.html. It probably looks at http://example.org/css/ for the css file. This is on purpose, as this theme package uses absolute URLs for it's recourse paths.

It should work if you enter the correct baseURL in config.toml and upload your site.

If you want to use it locally as well, you have to change the link to the styles.css in your-site/themes/your-theme/layouts/partials/head.html:

- <link rel="stylesheet" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}">
+ <link rel="stylesheet" href="{{ $style.RelPermalink }}" integrity="{{ $style.Data.Integrity }}">

See the Hugo docs for page resources.