This document outlines the necessary changes to the `package.json` file when starting a new project based on HBStack. It includes details on updating project metadata, repository links, and other essential configurations.
This document outlines the necessary changes to the `package.json` file when starting a new project based on HBStack. It includes details on updating project metadata, repository links, and other essential configurations.
The package.json file contains critical metadata about your project, including its name, repository URL, and other identifying information. When starting a new project based on HBStack, you should update this file to reflect your own project’s details.
The default package.json file for HBStack contains the following configuration:
1{
2 "name": "hb-theme",
3 "description": "The starter theme template of [HB Framework](https://hbstack.dev/).",
4 "scripts": {},
5 "repository": {
6 "type": "git",
7 "url": "git+https://github.com/hbstack/theme.git"
8 },
9 "author": "Razon Yang <razonyang@gmail.com>",
10 "license": "MIT",
11 "bugs": {
12 "url": "https://github.com/hbstack/theme/issues"
13 },
14 "homepage": "https://github.com/hbstack/theme#readme",
15 "devDependencies": {
16 "@fullhuman/postcss-purgecss": "^7.0.0",
17 "autoprefixer": "^10.4.14",
18 "postcss-cli": "^11.0.0",
19 "prettier": "^2.8.8",
20 "prettier-plugin-go-template": "^0.0.13",
21 "prettier-plugin-md-nocjsp": "^1.5.1",
22 "rtlcss": "^4.0.0"
23 },
24 "dependencies": {
25 "@hbstack/node-packages": "^0.1.5"
26 }
27}
For this project, we need to update several fields to reflect the project name hugo-with-docker or whatever is your repo name. Here are the specific changes required:
hb-theme to hugo-with-dockerHere’s how the updated package.json file should look:
1{
2 "name": "hugo-with-docker",
3 "description": "A Hugo project based on HBStack framework with Docker integration",
4 "version": "0.1.0",
5 "scripts": {
6 "dev": "hugo server",
7 "build": "hugo --minify",
8 "clean": "rm -rf public resources",
9 "test": "hugo server --disableFastRender",
10 "debug": "hugo server --debug --verbose --logLevel debug",
11 "debug:build": "hugo --debug --verbose --logLevel debug --minify",
12 "diagnose": "echo '=== Hugo Diagnostics ===' && hugo version && echo '\\n=== Hugo Environment ===' && hugo env && echo '\\n=== Hugo Config ===' && hugo config",
13 "troubleshoot": "echo '=== Project Health Check ===' && npm run diagnose && echo '\\n=== Module Status ===' && npm run check:modules && echo '\\n=== Build Test ===' && npm run check:build",
14 "check:links": "hugo server --navigateToChanged=false --disableFastRender --logLevel info 2>&1 | grep -i 'error\\|warn' || echo 'No link errors found'",
15 "check:config": "hugo config --logLevel info",
16 "check:modules": "hugo mod verify && hugo mod graph",
17 "check:build": "hugo --dry-run --logLevel info",
18 "health": "echo '=== Quick Health Check ===' && hugo version && hugo mod verify && hugo config | head -20"
19 },
20 "repository": {
21 "type": "git",
22 "url": "git+https://github.com/agsayyed/hugo-with-docker.git"
23 },
24 "keywords": ["hugo", "hbstack", "docker", "static-site"],
25 "author": "AG Sayyed <s.ghafoor@outlook.com>",
26 "license": "MIT",
27 "bugs": {
28 "url": "https://github.com/agsayyed/hugo-with-docker/issues"
29 },
30 "homepage": "https://github.com/agsayyed/hugo-with-docker#readme",
31 "devDependencies": {
32 "@fullhuman/postcss-purgecss": "^7.0.0",
33 "autoprefixer": "^10.4.14",
34 "postcss-cli": "^11.0.0",
35 "prettier": "^2.8.8",
36 "prettier-plugin-go-template": "^0.0.13",
37 "prettier-plugin-md-nocjsp": "^1.5.1",
38 "rtlcss": "^4.0.0"
39 },
40 "dependencies": {
41 "@hbstack/node-packages": "^0.1.5"
42 }
43}
Updating the package.json file ensures:
scripts section based on your workflowOpen the package.json file in your project root
Update the fields as shown above, replacing placeholder values with your actual information
Save the file
If you’re using version control, commit these changes:
1git add package.json
2git commit -m "Update package.json with project-specific information"
By making these changes, your project will be properly configured with its own identity while maintaining the benefits of the HBStack framework.
In addition to the basic project metadata updates, we’ve added comprehensive debugging and troubleshooting scripts to help maintain and diagnose issues with your Hugo project. These scripts provide valuable insights into your project’s health and can help quickly identify common problems.
The following scripts have been added to the scripts section of package.json:
1{
2 "scripts": {
3 "dev": "hugo server",
4 "build": "hugo --minify",
5 "clean": "rm -rf public resources",
6 "test": "hugo server --disableFastRender",
7 "debug": "hugo server --debug --verbose --logLevel debug",
8 "debug:build": "hugo --debug --verbose --logLevel debug --minify",
9 "diagnose": "echo '=== Hugo Diagnostics ===' && hugo version && echo '\\n=== Hugo Environment ===' && hugo env && echo '\\n=== Hugo Config ===' && hugo config",
10 "troubleshoot": "echo '=== Project Health Check ===' && npm run diagnose && echo '\\n=== Module Status ===' && npm run check:modules && echo '\\n=== Build Test ===' && npm run check:build",
11 "check:links": "hugo server --navigateToChanged=false --disableFastRender --logLevel info 2>&1 | grep -i 'error\\|warn' || echo 'No link errors found'",
12 "check:config": "hugo config --logLevel info",
13 "check:modules": "hugo mod verify && hugo mod graph",
14 "check:build": "hugo --dry-run --logLevel info",
15 "health": "echo '=== Quick Health Check ===' && hugo version && hugo mod verify && hugo config | head -20"
16 }
17}
dev: Standard Hugo development serverbuild: Production build with minificationclean: Remove generated files and resourcestest: Development server without fast render for testingdebug: Start Hugo server with full debug output and verbose loggingdebug:build: Build with full debug information and verbose loggingdiagnose: Comprehensive system diagnostics showing Hugo version, environment, and configurationtroubleshoot: Full project health check combining multiple diagnostic checkshealth: Quick health check for immediate project statuscheck:links: Check for broken links and navigation issuescheck:config: Validate Hugo configuration filescheck:modules: Verify and display Hugo module dependenciescheck:build: Perform a dry-run build to check for build issues1# Quick project health check
2npm run health
3
4# Full diagnostic information
5npm run diagnose
6
7# Complete troubleshooting session
8npm run troubleshoot
1# Debug development server issues
2npm run debug
3
4# Debug build problems
5npm run debug:build
1# Check Hugo modules
2npm run check:modules
3
4# Validate configuration
5npm run check:config
6
7# Test build without generating files
8npm run check:build
These scripts provide several advantages:
npm run health to ensure everything is workingnpm run troubleshoot for comprehensive diagnosisnpm run check:modules to verify dependenciesnpm run check:config to validate settingsnpm run debug to identify bottlenecks