Skip to content

Commit f05a281

Browse files
committed
[CI] Migrate to npm-managed local Hugo and standardise Makefile targets
Signed-off-by: Heby T Paul <hebytpaul1111@gmail.com>
1 parent 501487a commit f05a281

4 files changed

Lines changed: 35 additions & 20 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ make site
9898

9999
#### Building the Site
100100

101-
To build the Academy site for production, ensure you have `Hugo` and `Go` installed. Now, run the following command to build the site:
101+
To build the Academy site for production, ensure you have `npm` and `Go` installed. The local `hugo` binary is managed by `npm`. Ensure you have run `make setup` first, then run the following command to build the site:
102102

103103
```sh
104104
make build

Makefile

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,33 @@ include .github/build/Makefile.show-help.mk
2323
setup:
2424
npm install
2525

26-
## Build and run site locally with draft and future content enabled.
27-
site: check-go
28-
hugo server -D -F
26+
## Verify required commands and local dependencies are present.
27+
check-deps:
28+
@echo "Checking if 'npm' and local 'hugo' binary are present..."
29+
@command -v npm > /dev/null || { echo "Error: 'npm' not found. Please install Node.js and npm."; exit 1; }
30+
@test -x node_modules/.bin/hugo || { echo "Error: Hugo binary not found in node_modules. Please run 'make setup' first."; exit 1; }
31+
@echo "Dependencies check passed."
32+
33+
## Run on your local machine with draft and future content enabled.
34+
site: check-deps check-go
35+
npm run dev:site
36+
37+
## Run on your local machine without file watching.
38+
serve: check-deps check-go
39+
npm run dev:serve
2940

3041
## Build site
31-
build:
32-
hugo build
42+
build: check-deps check-go
43+
npm run dev:build
3344

3445
## Build site for local consumption
35-
build-preview:
36-
hugo --baseURL=$(BASEURL)
46+
build-preview: check-deps check-go
47+
npm run dev:build -- --baseURL="$(BASEURL)"
3748

3849
## Empty build cache and run on your local machine.
3950
clean:
40-
hugo --cleanDestinationDir
41-
make setup
42-
make site
51+
npm run clean
52+
$(MAKE) site
4353

4454
## Fix Markdown linting issues
4555
lint-fix:
@@ -61,8 +71,8 @@ check-go:
6171
@echo "Go is installed."
6272

6373
## Update the academy-theme package to latest version
64-
theme-update:
74+
theme-update: check-deps
6575
echo "Updating to latest academy-theme..." && \
66-
hugo mod get github.com/layer5io/academy-theme
76+
npm run update:theme
6777

68-
.PHONY: setup build build-preview site clean lint-fix check-go theme-update
78+
.PHONY: setup check-deps build build-preview site serve clean check-go theme-update lint-fix

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Layer5 Academy
22

33
**Layer5 Academy** is the **official content repository** for Layer5's learning platform, hosting all official learning paths, challenges, and certifications.
4-
It is built with [Hugo](https://gohugo.io/) and integrated into a multi-repository architecture for rapid local preview and automated cloud deployment.
4+
It is built with [Hugo](https://gohugo.io/) (managed locally via npm) and integrated into a multi-repository architecture for rapid local preview and automated cloud deployment.
55

66
---
77

@@ -41,12 +41,13 @@ The Academy platform is composed of multiple repositories, each with a specific
4141
## Quick Start (Local Preview)
4242

4343
> Use this workflow for a fast preview loop when editing Markdown content.
44+
> **Note:** You do not need to install Hugo globally. The required `hugo-extended` binary is managed locally via npm when you run `make setup`.
4445
4546
```bash
4647
# Clean up and verify Go module dependencies
4748
go mod tidy
4849

49-
# Install necessary tools and modules
50+
# Install necessary tools and modules (including local Hugo)
5051
make setup
5152

5253
# Start the local Hugo development server

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@
1313
"_build": "npm run _hugo-dev --",
1414
"_check:links": "echo IMPLEMENTATION PENDING for check-links; echo",
1515
"_hugo": "hugo --cleanDestinationDir",
16-
"_hugo-dev": "npm run _hugo -- -e dev -DFE",
17-
"_local": "npx cross-env HUGO_MODULE_WORKSPACE=docsy.work",
18-
"_serve": "npm run _hugo-dev -- --minify serve --renderToMemory",
16+
"_hugo-dev": "hugo --cleanDestinationDir -e dev -DFE",
17+
"_local": "cross-env HUGO_MODULE_WORKSPACE=docsy.work",
18+
"_serve": "npm run _hugo-dev -- server --minify --renderToMemory",
1919
"build:preview": "npm run _hugo-dev -- --minify --baseURL \"${DEPLOY_PRIME_URL:-/}\"",
2020
"build:production": "npm run _hugo -- --minify",
2121
"build": "npm run _build -- ",
2222
"check:links:all": "HTMLTEST_ARGS= npm run _check:links",
2323
"check:links": "npm run _check:links",
2424
"clean": "rm -Rf public/* resources",
25+
"dev:build": "npm run _hugo-dev --",
26+
"dev:serve": "npm run _hugo-dev -- server --watch=false",
27+
"dev:site": "npm run _hugo-dev -- server",
2528
"local": "npm run _local -- npm run",
2629
"make:public": "git init -b main public",
2730
"precheck:links:all": "npm run build",
@@ -32,7 +35,8 @@
3235
"test": "npm run check:links",
3336
"update:dep": "npm install --save-dev autoprefixer@latest postcss-cli@latest",
3437
"update:hugo": "npm install --save-dev --save-exact hugo-extended@latest",
35-
"update:pkgs": "npx npm-check-updates -u"
38+
"update:pkgs": "npx npm-check-updates -u",
39+
"update:theme": "hugo mod get github.com/layer5io/academy-theme"
3640
},
3741
"devDependencies": {
3842
"autoprefixer": "^10.4.21",

0 commit comments

Comments
 (0)