by Sai gowtham

How to deploy a nuxt app to GitHub Pages

In this tutorial, we are going to learn about how to host your nuxt app to GitHub pages by using the command line.

Deploying to GitHub Pages

  1. First, create a new repository in GitHub and push your nuxt app to it.

nuxt app to GitHub repository

  1. Now, open your nuxt.config.js file and add the following configuration to the export default object.
nuxt.config.js
export default {
   mode: 'static',
   router: {
      base: '/your-github-repository-name/'
   },
   // other config goes here
}
  1. Install the gh-pages package by using the below command.
npm install gh-pages --save-dev
  1. Add the following deploy commands to your package.json file scripts object.
"predeploy": "nuxt generate",
"deploy": "gh-pages -d dist"
  1. Run the following command to successfully deploy your app to GitHub pages.
npm run deploy

Now, open your nuxt app GitHub repository and click on the settings tab, if your scroll down to the GitHub Pages section you will see a nuxt app live URL like this.

nuxt app deploy url GitHub pages

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
45,614 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
284,472 students enrolled
40 hours of video content
View Course
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
130,921 students enrolled
48.5 hours of video content
View Course