Hugo 內建的 Web Server 只能用在 開發階段,無法用在編譯後的 HTML/CSS/JavaScript,需要透過其他 Web Server。
Version
Hugo 0.161.1
NPM Script
package.json
{
"name": "hugo-theme",
"version": "1.0.0",
"scripts": {
"dev": "hugo server --disableFastRender",
"build": "hugo --cleanDestinationDir --minify",
"prettier": "prettier --write '**/*.{html,css,js,toml}'",
"stylelint": "npx stylelint '**/*.{css}' --fix",
"serve": "python3 -m http.server --directory public"
}
}
第 9 行
"serve": "python3 -m http.server --directory public"
python3:使用 macOS 內建的 Python 3-m http.server:使用 Python 內建的http.server模組啟動 Web Server--directory public:Web Server 執行public目錄下的 HTML/CSS/JavaScript
Conclusion
- macOS 內建的 Python 已經內建 Web Server,不必再另外下載