You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
-126Lines changed: 0 additions & 126 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,132 +72,6 @@ Modify these files to customize behavior:
72
72
## License
73
73
MIT License (see LICENSE.txt)
74
74
75
-
---
76
-
77
-
## Deploy to GitHub Pages with CI/CD
78
-
79
-
You can deploy this Next.js App Router project to GitHub Pages using GitHub Actions. GitHub Pages serves static files, so we’ll use Next’s static export.
// assetPrefix helps static assets resolve under the basePath
104
-
// assetPrefix: process.env.NEXT_PUBLIC_BASE_PATH
105
-
// ? `${process.env.NEXT_PUBLIC_BASE_PATH}/`
106
-
// : undefined,
107
-
};
108
-
109
-
exportdefaultnextConfig;
110
-
```
111
-
112
-
Notes:
113
-
- If you deploy to Project Pages (repo site at https://<user>.github.io/<repo>), you must set basePath to "/<repo>" (and optionally assetPrefix) for client-side routing and assets to work.
114
-
- If you deploy to User/Org Pages (https://<user>.github.io), leave basePath empty.
115
-
116
-
### 3) Add a GitHub Actions workflow
117
-
Create .github/workflows/deploy.yml in your repo with:
118
-
119
-
```yaml
120
-
name: Deploy to GitHub Pages
121
-
122
-
on:
123
-
push:
124
-
branches: [ main ]
125
-
workflow_dispatch:
126
-
127
-
permissions:
128
-
contents: read
129
-
pages: write
130
-
id-token: write
131
-
132
-
concurrency:
133
-
group: pages
134
-
cancel-in-progress: true
135
-
136
-
jobs:
137
-
build:
138
-
runs-on: ubuntu-latest
139
-
steps:
140
-
- name: Checkout
141
-
uses: actions/checkout@v4
142
-
143
-
- name: Setup Node
144
-
uses: actions/setup-node@v4
145
-
with:
146
-
node-version: "20"
147
-
cache: npm
148
-
149
-
- name: Install dependencies
150
-
run: npm ci
151
-
152
-
- name: Build (Turbopack)
153
-
run: npm run build
154
-
155
-
- name: Static export
156
-
run: npx next export
157
-
158
-
- name: Upload Pages artifact
159
-
uses: actions/upload-pages-artifact@v3
160
-
with:
161
-
path: out
162
-
163
-
deploy:
164
-
runs-on: ubuntu-latest
165
-
needs: build
166
-
environment:
167
-
name: github-pages
168
-
url: ${{ steps.deployment.outputs.page_url }}
169
-
steps:
170
-
- name: Deploy to GitHub Pages
171
-
id: deployment
172
-
uses: actions/deploy-pages@v4
173
-
```
174
-
175
-
Then, in your GitHub repository:
176
-
- Settings → Pages → Source: “Deploy from a branch” or “GitHub Actions” → select GitHub Actions.
177
-
178
-
Optional: For Project Pages, set the base path via environment variable
179
-
- In the workflow, add:
180
-
```yaml
181
-
env:
182
-
NEXT_PUBLIC_BASE_PATH: "/<repo>"
183
-
```
184
-
and uncomment basePath/assetPrefix in next.config.ts.
185
-
186
-
### 4) Test locally (optional)
187
-
- Build and export:
188
-
- npm run build
189
-
- npx next export
190
-
- Serve the static site locally:
191
-
- npx serve out -p 5000
192
-
- Open http://localhost:5000 (or http://localhost:5000/<repo> if using basePath).
193
-
194
-
### 5) Limitations and tips
195
-
- GitHub Pages is static-only. Avoid server-only features (API routes, dynamic SSR) when using output: "export".
196
-
- This project primarily uses client components and should export cleanly.
197
-
- If you need SSR or Edge functions, prefer deploying to Vercel.
0 commit comments