nextjs / deploy-github-pages

Next.js template to deploy to GitHub Pages as a static site.
36 stars 6 forks source link

Deploy Next.js to GitHub Pages

This is a Next.js template which can be deployed to GitHub Pages as a static site.

Deploying to GitHub Pages

  1. Create a new public GitHub repository
  2. Edit next.config.ts to match your GitHub repository name:
    • Given the pattern https://github.com/<user>/<repo>
    • Update your basePath config to the name of your repo (e.g. /repo)
  3. Push the starter code to the main branch
  4. Run the deploy script (e.g. npm run deploy) to create the gh-pages branch
  5. On GitHub, go to Settings > Pages > Branch, and choose gh-pages as the branch with the /root folder. Hit Save
  6. Make a change
  7. Run the deploy script again to push the changes to GitHub Pages

Congratulations! You should have a URL like:

https://<github-user-name>.github.io/<github-project-name>/

For more information, see our deployment documentation.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!