jpanther / congo

A powerful, lightweight theme for Hugo built with Tailwind CSS.
https://jpanther.github.io/congo/
MIT License
1.19k stars 318 forks source link

Building Congo v2.1.0 on Cloudflare Pages #157

Closed strauhmanis closed 2 years ago

strauhmanis commented 2 years ago

What happened?

Hello,

I'm having a trouble building Congo (manual install method) on Cloudflare Pages.

Build command = npm run build Build output directory = public

Please see the attached build log.

Would appreciate your comment, please.

Thank you!

Theme version

v2.1.0

Hugo version

v0.95.0

What browsers are you seeing the problem on?

Safari

Relevant Hugo log output

13:29:06.903    Initializing build environment. This may take up to a few minutes to complete
13:29:09.016    Success: Finished initializing build environment
13:29:09.016    Cloning repository...
13:29:10.984    Success: Finished cloning repository files
13:29:11.265    Installing dependencies
13:29:11.277    Python version set to 2.7
13:29:13.528    Attempting node version 'v16.14.2' from .nvmrc
13:29:15.225    Downloading and installing node v16.14.2...
13:29:15.702    Downloading https://nodejs.org/dist/v16.14.2/node-v16.14.2-linux-x64.tar.xz...
13:29:16.130    Computing checksum with sha256sum
13:29:16.263    Checksums matched!
13:29:20.726    Now using node v16.14.2 (npm v8.5.0)
13:29:21.319    Started restoring cached build plugins
13:29:21.335    Finished restoring cached build plugins
13:29:22.061    Attempting ruby version 2.7.1, read from environment
13:29:27.978    Using ruby version 2.7.1
13:29:28.341    Using PHP version 5.6
13:29:28.518    5.2 is already installed.
13:29:28.546    Using Swift version 5.2
13:29:28.547    Started restoring cached node modules
13:29:28.567    Finished restoring cached node modules
13:29:29.037    Installing NPM modules using NPM version 8.5.0
13:29:32.689    npm WARN deprecated @braintree/sanitize-url@3.1.0: Potential XSS vulnerability patched in v6.0.0.
13:29:34.506    
13:29:34.506    > hugo-congo-theme@2.1.0 preinstall
13:29:34.506    > rimraf assets/vendor
13:29:34.506    
13:29:34.615    
13:29:34.615    > hugo-congo-theme@2.1.0 postinstall
13:29:34.615    > vendor-copy
13:29:34.615    
13:29:34.718    /opt/buildhome/repo/node_modules/mermaid/dist/mermaid.min.js => /opt/buildhome/repo/assets/lib/mermaid/mermaid.min.js
13:29:34.718    /opt/buildhome/repo/node_modules/chart.js/dist/chart.min.js => /opt/buildhome/repo/assets/lib/chart/chart.min.js
13:29:34.718    /opt/buildhome/repo/node_modules/katex/dist/katex.min.js => /opt/buildhome/repo/assets/lib/katex/katex.min.js
13:29:34.718    /opt/buildhome/repo/node_modules/katex/dist/katex.min.css => /opt/buildhome/repo/assets/lib/katex/katex.min.css
13:29:34.718    /opt/buildhome/repo/node_modules/katex/dist/contrib/auto-render.min.js => /opt/buildhome/repo/assets/lib/katex/auto-render.min.js
13:29:34.718    /opt/buildhome/repo/node_modules/katex/dist/fonts/ => /opt/buildhome/repo/assets/lib/katex/fonts/
13:29:34.718    /opt/buildhome/repo/node_modules/fuse.js/dist/fuse.min.js => /opt/buildhome/repo/assets/lib/fuse/fuse.min.js
13:29:34.749    
13:29:34.750    added 203 packages, and audited 204 packages in 5s
13:29:34.750    
13:29:34.750    23 packages are looking for funding
13:29:34.750      run `npm fund` for details
13:29:34.757    
13:29:34.757    3 vulnerabilities (2 moderate, 1 high)
13:29:34.757    
13:29:34.757    To address issues that do not require attention, run:
13:29:34.757      npm audit fix
13:29:34.757    
13:29:34.757    To address all issues (including breaking changes), run:
13:29:34.757      npm audit fix --force
13:29:34.757    
13:29:34.757    Run `npm audit` for details.
13:29:34.768    NPM modules installed
13:29:35.306    Installing Hugo 0.95.0
13:29:36.533    hugo v0.95.0-9F2E76AF+extended linux/amd64 BuildDate=2022-03-16T14:20:19Z VendorInfo=gohugoio
13:29:36.538    Started restoring cached go cache
13:29:36.561    Finished restoring cached go cache
13:29:36.720    go version go1.14.4 linux/amd64
13:29:36.741    go version go1.14.4 linux/amd64
13:29:36.745    Installing missing commands
13:29:36.745    Verify run directory
13:29:36.745    Executing user command: npm run build
13:29:37.217    
13:29:37.217    > hugo-congo-theme@2.1.0 build
13:29:37.217    > NODE_ENV=production ./node_modules/tailwindcss/lib/cli.js -i ./assets/css/main.css -o ./assets/css/compiled/main.css --jit
13:29:37.217    
13:29:38.426    
13:29:38.426    warn - The RTL features in Tailwind CSS are currently in preview.
13:29:38.427    warn - Preview features are not covered by semver, and may be improved in breaking ways at any time.
13:29:38.676    
13:29:38.676    Done in 599ms.
13:29:38.704    Finished
13:29:38.705    Note: No functions dir at /functions found. Skipping.
13:29:38.705    Validating asset output directory
13:29:38.705    Error: Output directory "public" not found.
MoshiBin commented 2 years ago

Your build commands doesn't look right. This theme is for Hugo, so your build command should be hugo. You can see more details about deploying Hugo sites to Cloudflare Pages in their official docs:

Configuration option | Value -- | -- Production branch | main Build command | hugo Build directory | public
strauhmanis commented 2 years ago

I tried building with the hugo command at a very first try, but there was even less build progress that way.

I tried once again and had a same unsuccessful result — please see the log below:

08:22:19.658 Initializing build environment. This may take up to a few minutes to complete 08:22:21.733 Success: Finished initializing build environment 08:22:21.733 Cloning repository... 08:22:23.962 Success: Finished cloning repository files 08:22:24.237 Installing dependencies 08:22:24.249 Python version set to 2.7 08:22:26.510 Attempting node version 'v16.14.2' from .nvmrc 08:22:28.228 Downloading and installing node v16.14.2... 08:22:28.727 Downloading https://nodejs.org/dist/v16.14.2/node-v16.14.2-linux-x64.tar.xz... 08:22:29.146 Computing checksum with sha256sum 08:22:29.281 Checksums matched! 08:22:33.797 Now using node v16.14.2 (npm v8.5.0) 08:22:34.385 Started restoring cached build plugins 08:22:34.401 Finished restoring cached build plugins 08:22:35.122 Attempting ruby version 2.7.1, read from environment 08:22:41.112 Using ruby version 2.7.1 08:22:41.482 Using PHP version 5.6 08:22:41.657 5.2 is already installed. 08:22:41.684 Using Swift version 5.2 08:22:41.685 Started restoring cached node modules 08:22:41.710 Finished restoring cached node modules 08:22:42.189 Installing NPM modules using NPM version 8.5.0 08:22:45.755 npm WARN deprecated @braintree/sanitize-url@3.1.0: Potential XSS vulnerability patched in v6.0.0. 08:22:47.689
08:22:47.689 > hugo-congo-theme@2.1.0 preinstall 08:22:47.689 > rimraf assets/vendor 08:22:47.689
08:22:47.803
08:22:47.804 > hugo-congo-theme@2.1.0 postinstall 08:22:47.804 > vendor-copy 08:22:47.804
08:22:47.905 /opt/buildhome/repo/node_modules/mermaid/dist/mermaid.min.js => /opt/buildhome/repo/assets/lib/mermaid/mermaid.min.js 08:22:47.905 /opt/buildhome/repo/node_modules/chart.js/dist/chart.min.js => /opt/buildhome/repo/assets/lib/chart/chart.min.js 08:22:47.905 /opt/buildhome/repo/node_modules/katex/dist/katex.min.js => /opt/buildhome/repo/assets/lib/katex/katex.min.js 08:22:47.905 /opt/buildhome/repo/node_modules/katex/dist/katex.min.css => /opt/buildhome/repo/assets/lib/katex/katex.min.css 08:22:47.906 /opt/buildhome/repo/node_modules/katex/dist/contrib/auto-render.min.js => /opt/buildhome/repo/assets/lib/katex/auto-render.min.js 08:22:47.906 /opt/buildhome/repo/node_modules/katex/dist/fonts/ => /opt/buildhome/repo/assets/lib/katex/fonts/ 08:22:47.906 /opt/buildhome/repo/node_modules/fuse.js/dist/fuse.min.js => /opt/buildhome/repo/assets/lib/fuse/fuse.min.js 08:22:47.941
08:22:47.941 added 203 packages, and audited 204 packages in 5s 08:22:47.941
08:22:47.941 23 packages are looking for funding 08:22:47.941 run npm fund for details 08:22:47.947
08:22:47.947 3 vulnerabilities (2 moderate, 1 high) 08:22:47.947
08:22:47.947 To address issues that do not require attention, run: 08:22:47.947 npm audit fix 08:22:47.947
08:22:47.948 To address all issues (including breaking changes), run: 08:22:47.948 npm audit fix --force 08:22:47.948
08:22:47.948 Run npm audit for details. 08:22:47.959 NPM modules installed 08:22:48.501 Installing Hugo 0.96.0 08:22:49.795 hugo v0.96.0-2fd4a7d3d6845e75f8b8ae3a2a7bd91438967bbb+extended linux/amd64 BuildDate=2022-03-26T09:15:58Z VendorInfo=gohugoio 08:22:49.801 Started restoring cached go cache 08:22:49.824 Finished restoring cached go cache 08:22:49.988 go version go1.14.4 linux/amd64 08:22:50.009 go version go1.14.4 linux/amd64 08:22:50.014 Installing missing commands 08:22:50.014 Verify run directory 08:22:50.014 Executing user command: hugo 08:22:50.058 Error: module "congo" not found; either add it as a Hugo Module or store it in "/opt/buildhome/repo/themes".: module does not exist 08:22:50.058 Total in 5 ms 08:22:50.068 Failed: build command exited with code: 255

MoshiBin commented 2 years ago

Try installing congo as a submodule. I don't see any reference to hugo mods in the Cloudflare docs, only to installing themes as submodules.

jpanther commented 2 years ago

Unless you specifically need to build a custom version of the theme you shouldn't need to run npm as part of your site build. If you're using the manual installation method, simply build your site using the hugo command.

08:22:50.058 Error: module "congo" not found; either add it as a Hugo Module or store it in "/opt/buildhome/repo/themes".: module does not exist

This error suggests that it can't find the theme. Does the directory themes/congo exist in your deployment? If so, it may be that you are missing the line theme = "congo" in your Hugo config file.

andrewrjones commented 2 years ago

I've been able to deploy a Congo themed site successfully with Cloudflare pages.

I've installed Congo through a Git submodule. My config file is simply:

> cat config.toml
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: config.toml
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ theme = "congo"
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Build config (the default for Hugo):

CleanShot 2022-04-20 at 14 44 07

Environment variable to use the latest version of Hugo:

CleanShot 2022-04-20 at 14 44 12

Cloudflare log:

14:23:14.843 | Initializing build environment. This may take up to a few minutes to complete
-- | --
14:23:17.034 | Success: Finished initializing build environment
14:23:17.034 | Cloning repository...
14:23:20.498 | Success: Finished cloning repository files
14:23:20.822 | Installing dependencies
14:23:20.833 | Python version set to 2.7
14:23:24.930 | v12.18.0 is already installed.
14:23:26.309 | Now using node v12.18.0 (npm v6.14.4)
14:23:26.647 | Started restoring cached build plugins
14:23:26.663 | Finished restoring cached build plugins
14:23:27.370 | Attempting ruby version 2.7.1, read from environment
14:23:33.297 | Using ruby version 2.7.1
14:23:33.662 | Using PHP version 5.6
14:23:33.833 | 5.2 is already installed.
14:23:33.862 | Using Swift version 5.2
14:23:33.862 | Installing Hugo 0.96.0
14:23:34.996 | hugo v0.96.0-2fd4a7d3d6845e75f8b8ae3a2a7bd91438967bbb+extended linux/amd64 BuildDate=2022-03-26T09:15:58Z VendorInfo=gohugoio
14:23:35.001 | Started restoring cached go cache
14:23:35.028 | Finished restoring cached go cache
14:23:35.180 | go version go1.14.4 linux/amd64
14:23:35.201 | go version go1.14.4 linux/amd64
14:23:35.206 | Installing missing commands
14:23:35.206 | Verify run directory
14:23:35.206 | Executing user command: hugo
14:23:35.290 | Start building sites …
14:23:35.290 | hugo v0.96.0-2fd4a7d3d6845e75f8b8ae3a2a7bd91438967bbb+extended linux/amd64 BuildDate=2022-03-26T09:15:58Z VendorInfo=gohugoio
14:23:35.315 |  
14:23:35.315 | \| EN
14:23:35.315 | -------------------+-----
14:23:35.315 | Pages            \|  9
14:23:35.315 | Paginator pages  \|  0
14:23:35.315 | Non-page files   \|  0
14:23:35.315 | Static files     \|  7
14:23:35.315 | Processed images \|  0
14:23:35.315 | Aliases          \|  0
14:23:35.315 | Sitemaps         \|  1
14:23:35.316 | Cleaned          \|  0
14:23:35.316 |  
14:23:35.316 | Total in 71 ms
14:23:35.326 | Finished
14:23:35.327 | Note: No functions dir at /functions found. Skipping.
14:23:35.327 | Validating asset output directory
14:23:35.948 | Deploying your site to Cloudflare's global network...
14:23:41.711 | Success: Your site was deployed!
strauhmanis commented 2 years ago

Thank you all!

I'm now successfully building Congo Cloudflare Pages.