Autobuild Nextjs github pages
Posted on September 2, 2022
Tags: javascript
add to package.json
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"export" : "next export"
}
npm export builds static pages into the out folder
steps:
....
....
- run: npm run export
- run: touch ./out/.nojekyll
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@4.1.5
with:
branch: gh-pages # The branch the action should deploy to.
folder: out # The folder the action should deploy.
on your github.com/
Select Source Choose “Branch: gh-pages” “/ (root)” Save
0.0.1 Follow through
in your next.config.js
.exports = {
modulebasePath: '/reponame',
assetPrefix: '/reponame'
}
You may notice GET ERR_ABORTED 404 on your www.github.io/repoName/_next/…
Github runs jekyll on every underscore folder including “_next” folders which we don’t want create a “.nojekyll” file, we already did that for you in the github actions command