This article lists some common problems so that you can easily solve them.

CSS rendering incorrectly#

Purge CSS

The problem probably due to the postcss, HBS need the following configuration to be set up, postcss rely on the file hugo_stats.json for purging unused CSS.

1[build]
2  writeStats = true

js.Build: Could not resolve dependencies#

 1Start building sites … 
 2hugo v0.94.0-63B23660+extended linux/amd64 BuildDate=2022-03-10T09:46:36Z VendorInfo=gohugoio
 3ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "bootstrap/js/src/offcanvas"
 4ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "bootstrap/js/src/modal"
 5ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "bootstrap/js/src/tab"
 6ERROR 2022/03/19 14:03:50 js.Build failed: "/home/razonyang/Projects/razonyang/hugo-theme-bootstrap/assets/js/collapse/collapse.ts:1:38": Could not resolve "bootstrap/js/src/collapse"
 7ERROR 2022/03/19 14:03:50 js.Build failed: "/home/razonyang/Projects/razonyang/hugo-theme-bootstrap/assets/js/toc/index.ts:1:27": Could not resolve "bootstrap/js/dist/offcanvas"
 8ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "@fortawesome/free-solid-svg-icons"
 9ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "@fortawesome/free-regular-svg-icons"
10ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "@fortawesome/free-brands-svg-icons"
11ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "workbox-routing"
12ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "workbox-strategies"
13ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "workbox-cacheable-response"
14ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "workbox-expiration"
15ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "workbox-precaching"
16ERROR 2022/03/19 14:03:50 js.Build failed: "/home/razonyang/Projects/razonyang/hugo-theme-bootstrap/assets/search/search.ts:1:21": Could not resolve "mustache"
17ERROR 2022/03/19 14:03:50 js.Build failed: "/home/razonyang/Projects/razonyang/hugo-theme-bootstrap/assets/search/search.ts:1:17": Could not resolve "mark.js/dist/mark.js"
18ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "bootstrap/js/src/offcanvas"
19ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "bootstrap/js/src/modal"
20ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "bootstrap/js/src/tab"
21ERROR 2022/03/19 14:03:50 js.Build failed: "/home/razonyang/Projects/razonyang/hugo-theme-bootstrap/assets/js/collapse/collapse.ts:1:38": Could not resolve "bootstrap/js/src/collapse"
22ERROR 2022/03/19 14:03:50 js.Build failed: "/home/razonyang/Projects/razonyang/hugo-theme-bootstrap/assets/js/toc/index.ts:1:27": Could not resolve "bootstrap/js/dist/offcanvas"
23ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "bootstrap/js/src/offcanvas"
24ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "bootstrap/js/src/modal"
25ERROR 2022/03/19 14:03:50 js.Build failed: Could not resolve "bootstrap/js/src/tab"
26ERROR 2022/03/19 14:03:50 js.Build failed: "/home/razonyang/Projects/razonyang/hugo-theme-bootstrap/assets/js/collapse/collapse.ts:1:38": Could not resolve "bootstrap/js/src/collapse"
27ERROR 2022/03/19 14:03:50 js.Build failed: "/home/razonyang/Projects/razonyang/hugo-theme-bootstrap/assets/js/toc/index.ts:1:27": Could not resolve "bootstrap/js/dist/offcanvas"
28ERROR 2022/03/19 14:03:51 js.Build failed: Could not resolve "bootstrap/js/src/offcanvas"
29ERROR 2022/03/19 14:03:51 js.Build failed: Could not resolve "bootstrap/js/src/modal"
30ERROR 2022/03/19 14:03:51 js.Build failed: Could not resolve "bootstrap/js/src/tab"
31ERROR 2022/03/19 14:03:51 js.Build failed: "/home/razonyang/Projects/razonyang/hugo-theme-bootstrap/assets/js/collapse/collapse.ts:1:38": Could not resolve "bootstrap/js/src/collapse"
32ERROR 2022/03/19 14:03:51 js.Build failed: "/home/razonyang/Projects/razonyang/hugo-theme-bootstrap/assets/js/toc/index.ts:1:27": Could not resolve "bootstrap/js/dist/offcanvas"
33ERROR 2022/03/19 14:03:51 TOCSS: failed to transform "viewer/scss/index.scss" (text/x-scss): SCSS processing failed: file "stdin", line 1, col 1: File to import not found or unreadable: viewerjs/dist/viewer. 
34ERROR 2022/03/19 14:03:51 JSBUILD: failed to transform "main/js/bundle.ts" (application/typescript): Could not resolve "bootstrap/js/src/dropdown"
35ERROR 2022/03/19 14:03:51 JSBUILD: failed to transform "icons/index.js" (application/javascript): Could not resolve "@fortawesome/fontawesome-svg-core"
36ERROR 2022/03/19 14:03:51 JSBUILD: failed to transform "service-worker/bundle.ts" (application/typescript): Could not resolve "workbox-core"
37ERROR 2022/03/19 14:03:51 JSBUILD: failed to transform "viewer/js/index.ts" (application/typescript): Could not resolve "viewerjs"
38Error: Error building site: JSBUILD: failed to transform "search/index.ts" (application/typescript): "/home/razonyang/Projects/razonyang/hugo-theme-bootstrap/assets/search/search.ts:1:17": Could not resolve "fuse.js"

It is due to the lack of CSS and JS dependencies:

1$ hugo mod npm pack
2$ npm install
3$ hugo server