Learn Nuxt with a Collection of 100+ Tips!
Deploy

GitLab Pages

Deploy your Nuxt Application to GitLab Pages.

Nuxt supports deploying on the GitLab Pages with minimal configuration.

GitLab Pages only support static sites, Nuxt will pre-render your application to static HTML files.
If you are not using a custom domain, you need to set NUXT_APP_BASE_URL to your repository-slug for your build step.Example: https://<group/user>.gitlab.io/<repository>/: NUXT_APP_BASE_URL=/<repository>/ npm run generate

Deployment

  1. Here is an example GitLab Pages workflow to deploy your site to GitLab Pages:
.gitlab-ci.yml
# Job name has to be `pages`. See https://docs.gitlab.com/ee/user/project/pages/#how-it-works
pages:
   image: node
   before_script:
      - npm ci --cache .npm --prefer-offline
   script:
      # Specify the steps involved to build your app here
      - npm run generate
   cache: # https://docs.gitlab.com/ee/ci/caching/#cache-nodejs-dependencies
      key:
         files:
         - package-lock.json
      paths:
         - .npm/
   artifacts:
      paths:
         # The directory that contains the built files to be published
         - .output/public
   # The directory that contains the built files to be published
   publish: .output/public
   rules:
      # This ensures that only pushes to the default branch 
      # will trigger a pages deploy
      - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH

Learn more

Head over GitLab Pages default domain names and URLs to learn more about the GitLab Pages default domain names.