Skip to content

Commit fab545f

Browse files
Anil KommareddiCopilot
andcommitted
Fix 404 local dev: add serve.json, recommend npx serve
python3 -m http.server does not serve 404.html for missing paths. npx serve does, matching GitHub Pages behaviour exactly. - Added serve.json (cleanUrls, no trailingSlash) for npx serve config - Updated README to flag the Python limitation and make npx serve the recommended local dev option Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1fe0ca7 commit fab545f

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,26 @@ Once DNS has propagated and the site is confirmed live, decommission the old Wor
2424

2525
## Testing locally
2626

27-
The site is plain static HTML — just serve the repo root with any local HTTP server. **Do not open `index.html` directly in a browser** (file:// breaks root-relative links like `/wp-content/...`).
27+
The site is plain static HTML — just serve the repo root with any local HTTP server. **Do not open `index.html` directly in a browser** (file:// breaks root-relative links like `/content/...`).
2828

29-
**Option 1 — Python (no install needed):**
29+
**Option 1 — Node.js `npx serve` (recommended):**
3030
```bash
31-
python3 -m http.server 8000
31+
npx serve .
3232
```
33+
> ✅ Automatically serves `404.html` for broken links, matching GitHub Pages behaviour exactly.
3334
34-
**Option 2 — Node.js (`npx`, no install needed):**
35+
**Option 2 — Python (no install needed):**
3536
```bash
36-
npx serve .
37+
python3 -m http.server 8000
3738
```
39+
> ⚠️ Does **not** serve `404.html` for missing paths — Python shows its own built-in error. Use `npx serve` to test 404 handling locally.
3840
3941
**Option 3 — Ruby (if you have it):**
4042
```bash
4143
ruby -run -e httpd . -p 8000
4244
```
4345

44-
Then open [http://localhost:8000](http://localhost:8000) in your browser.
46+
Then open [http://localhost:3000](http://localhost:3000) (npx serve) or [http://localhost:8000](http://localhost:8000) (Python/Ruby) in your browser.
4547

4648
---
4749

serve.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"cleanUrls": true,
3+
"trailingSlash": false
4+
}

0 commit comments

Comments
 (0)