Getting errors while deploying a Next.js site to GitHub Pages.
Unanswered
Giant Angora posted this in #help-forum
Giant AngoraOP
I'm trying to deploy my Next.js app using the App Router and pnpm to GitHub Pages, but I'm getting errors. Here's my setup:
###
###
Even with this setup, it's throwing errors during deployment also the css isn't working!
###
next.config.mjs:/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export",
images: {
unoptimized: true,
},
};
export default nextConfig;###
nextjs.yml (GitHub Actions workflow):name: Deploy Next.js site to Pages
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Install pnpm
run: |
npm install -g pnpm
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Restore cache
uses: actions/cache@v4
with:
path: |
.next/cache
node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}-
- name: Install dependencies
run: pnpm install
- name: Build with Next.js
run: pnpm next build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./out
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4Even with this setup, it's throwing errors during deployment also the css isn't working!
27 Replies
@gin dont do that
Giant AngoraOP
idk I just followed this: https://github.com/gregrickaby/nextjs-github-pages
is there a specific reason u are deploying to github pages?
Giant AngoraOP
yep
and what?
Giant AngoraOP
bc it's for an orgs, and Vercel requires a pro plan for org deployments. The Netlify site is also slow, so I thought GitHub Pages would be the best option.
@gin btw.
Giant AngoraOP
its just an static simple site
also I deploy one about a year ago and it worked but now I forgot about it also deleted the code but its was npm and now I'm using pnpm
Giant AngoraOP
yep
what exact issue do u have?
Giant AngoraOP
I'm not sure why the Netlify site is running slow.
@gin what exact issue do u have?
Giant AngoraOP
rn the site is working but the css isn't working
@Giant Angora rn the site is working but the css isn't working
Giant AngoraOP
+ Images
Giant AngoraOP
nope
also, I want to use a custom 404 page which is in app/not-found.tsx
@gin check in the network tab
Giant AngoraOP
iyk why netlify site is running show, then it will be good so I dont've to use github pages