Skip to content

Commit 7526abe

Browse files
Copilotrrrutledge
andcommitted
Fix CSS loading by setting proper baseURL for Codespaces using environment variables
Co-authored-by: rrrutledge <9609562+rrrutledge@users.noreply.github.com>
1 parent a66f0e9 commit 7526abe

3 files changed

Lines changed: 50 additions & 12 deletions

File tree

.vscode/launch.json

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,10 @@
33
"configurations": [
44
{
55
"name": "Hugo Server",
6-
"type": "pwa-node",
6+
"type": "node-terminal",
77
"request": "launch",
8-
"program": "${workspaceFolder}/node_modules/.bin/hugo",
9-
"args": [
10-
"server",
11-
"--bind=0.0.0.0",
12-
"--appendPort=false",
13-
"--baseURL=/",
14-
"--liveReloadPort=443",
15-
"-D"
16-
],
17-
"console": "integratedTerminal",
18-
"preLaunchTask": "Hugo: Check Environment"
8+
"command": "${workspaceFolder}/.vscode/start-hugo.sh",
9+
"cwd": "${workspaceFolder}"
1910
}
2011
]
2112
}

.vscode/start-hugo.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Determine the base URL for Hugo server
4+
# In Codespaces, use the Codespaces URL; otherwise, use localhost
5+
6+
if [ -n "$CODESPACE_NAME" ]; then
7+
# Running in GitHub Codespaces
8+
BASE_URL="https://${CODESPACE_NAME}-1313.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
9+
echo "🚀 Starting Hugo in Codespaces mode"
10+
echo "📍 Base URL: $BASE_URL"
11+
else
12+
# Running locally
13+
BASE_URL="http://localhost:1313"
14+
echo "🚀 Starting Hugo in local mode"
15+
echo "📍 Base URL: $BASE_URL"
16+
fi
17+
18+
# Start Hugo server with the appropriate configuration
19+
exec hugo server \
20+
--bind=0.0.0.0 \
21+
--baseURL="$BASE_URL" \
22+
--appendPort=false \
23+
--liveReloadPort=443 \
24+
-D

.vscode/tasks.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@
1010
"panel": "dedicated"
1111
},
1212
"problemMatcher": []
13+
},
14+
{
15+
"label": "Hugo: Start Server",
16+
"type": "shell",
17+
"command": "hugo server --bind=0.0.0.0 --appendPort=false --liveReloadPort=443 -D",
18+
"isBackground": true,
19+
"presentation": {
20+
"reveal": "always",
21+
"panel": "dedicated"
22+
},
23+
"problemMatcher": {
24+
"pattern": {
25+
"regexp": "^$",
26+
"file": 0,
27+
"location": 1,
28+
"message": 2
29+
},
30+
"background": {
31+
"activeOnStart": true,
32+
"beginsPattern": "^.*Building sites.*$",
33+
"endsPattern": "^.*Web Server is available.*$"
34+
}
35+
}
1336
}
1437
]
1538
}

0 commit comments

Comments
 (0)