Deployment

The following guides are based on some shared assumptions:

  • You are placing your Markdown source files inside the docs directory of your project;
  • You are using the default build output location (.vuepress/dist);
  • You are using yarn classicDeployment - 图1open in new window as package manager, while npm is also supported;
  • VuePress is installed as a local dependency in your project, and you have setup the following script in package.json:
  1. {
  2. "scripts": {
  3. "docs:build": "vuepress build docs"
  4. }
  5. }

GitHub Pages

  1. Set the correct base config.

    If you are deploying to https://<USERNAME>.github.io/, you can omit this step as base defaults to "/".

    If you are deploying to https://<USERNAME>.github.io/<REPO>/, for example your repository is at https://github.com/<USERNAME>/<REPO>, then set base to "/<REPO>/".

  2. Choose your preferred CI tools. Here we take GitHub ActionsDeployment - 图2open in new window as an example.

    Create .github/workflows/docs.yml to set up the workflow.

Click to expand sample config

  1. name: docs
  2. on:
  3. # trigger deployment on every push to main branch
  4. push:
  5. branches: [main]
  6. # trigger deployment manually
  7. workflow_dispatch:
  8. jobs:
  9. docs:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - uses: actions/checkout@v2
  13. with:
  14. # fetch all commits to get last updated time or other git log info
  15. fetch-depth: 0
  16. - name: Setup Node.js
  17. uses: actions/setup-node@v1
  18. with:
  19. # choose node.js version to use
  20. node-version: '14'
  21. # cache node_modules
  22. - name: Cache dependencies
  23. uses: actions/cache@v2
  24. id: yarn-cache
  25. with:
  26. path: |
  27. **/node_modules
  28. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  29. restore-keys: |
  30. ${{ runner.os }}-yarn-
  31. # install dependencies if the cache did not hit
  32. - name: Install dependencies
  33. if: steps.yarn-cache.outputs.cache-hit != 'true'
  34. run: yarn --frozen-lockfile
  35. # run build script
  36. - name: Build VuePress site
  37. run: yarn docs:build
  38. # please check out the docs of the workflow for more details
  39. # @see https://github.com/crazy-max/ghaction-github-pages
  40. - name: Deploy to GitHub Pages
  41. uses: crazy-max/ghaction-github-pages@v2
  42. with:
  43. # deploy to gh-pages branch
  44. target_branch: gh-pages
  45. # deploy the default output dir of VuePress
  46. build_dir: docs/.vuepress/dist

TIP

Please refer to GitHub Pages official guideDeployment - 图3open in new window for more details.

GitLab Pages

  1. Set the correct base config.

    If you are deploying to https://<USERNAME>.gitlab.io/, you can omit base as it defaults to "/".

    If you are deploying to https://<USERNAME>.gitlab.io/<REPO>/, for example your repository is at https://gitlab.com/<USERNAME>/<REPO>, then set base to "/<REPO>/".

  2. Create .gitlab-ci.yml to set up GitLab CIDeployment - 图4open in new window workflow.

Click to expand sample config

  1. # choose a docker image to use
  2. image: node:14-buster
  3. pages:
  4. # trigger deployment on every push to main branch
  5. only:
  6. - main
  7. # cache node_modules
  8. cache:
  9. paths:
  10. - node_modules/
  11. # install dependencies and run build script
  12. script:
  13. - yarn --frozen-lockfile
  14. - yarn docs:build --dest public
  15. artifacts:
  16. paths:
  17. - public

TIP

Please refer to GitLab Pages official guideDeployment - 图5open in new window for more details.

Google Firebase

  1. Make sure you have firebase-toolsDeployment - 图6open in new window installed.

  2. Create firebase.json and .firebaserc at the root of your project with the following content:

firebase.json:

  1. {
  2. "hosting": {
  3. "public": "./docs/.vuepress/dist",
  4. "ignore": []
  5. }
  6. }

.firebaserc:

  1. {
  2. "projects": {
  3. "default": "<YOUR_FIREBASE_ID>"
  4. }
  5. }
  1. After running yarn docs:build, deploy using the command firebase deploy.

TIP

Please refer to Firebase CLI official guideDeployment - 图7open in new window for more details.

Heroku

  1. Install Heroku CLIDeployment - 图8open in new window.

  2. Create a Heroku account by signing upDeployment - 图9open in new window.

  3. Run heroku login and fill in your Heroku credentials:

  1. heroku login
  1. Create a file called static.json in the root of your project with the below content:

static.json:

  1. {
  2. "root": "./docs/.vuepress/dist"
  3. }

This is the configuration of your site; read more at heroku-buildpack-staticDeployment - 图10open in new window.

Netlify

  1. On NetlifyDeployment - 图11open in new window, set up a new project from GitHub with the following settings:

    • Build Command: yarn docs:build
    • Publish directory: docs/.vuepress/dist
  2. Set Environment variablesDeployment - 图12open in new window to choose node version:

    • NODE_VERSION: 14
  3. Hit the deploy button.

Vercel

See Creating and Deploying a VuePress App with VercelDeployment - 图13open in new window.