1. Change the root path in vue.config.js to the repository name

module.exports = {
  publicPath: '/dq-todo/',
}
Copy the code

Because each project’s Github Pages are under a subpath with the same name as the repository, when the project is packaged, you need to set the resource path to match it.

Click Setting -> Pages -> Branch to select the Branch to store the package result. Here we are going to deploy -> Click Save

3. Write a deployment script to save money

#! /usr/bin/env sh

set -e

# Package build
yarn build

cd ./dist

Create a readme file and write the information
touch README.md
echo "# xxx"  >> README.md

git init
git add -A
git commit -m 'feat: deploy'

Set GIT_ADDRESS to git SSH, master to the current local branch, and deploy to the remote repository branch to be pushed
git push -f GIT_ADDRESS master:deploy
Copy the code

Add to package.json

"scripts": {
    "deploy": "sh deploy.sh"
 },
Copy the code

Command line operation

Yarn deploy // or NPM run deployCopy the code

Toy4. Wait a moment and you will see the deployed website ~