Skip to content

Instantly share code, notes, and snippets.

@claraj
Last active November 10, 2020 21:51
Show Gist options
  • Save claraj/188aa7a6cdef3dfb9af421dc5199f041 to your computer and use it in GitHub Desktop.
Save claraj/188aa7a6cdef3dfb9af421dc5199f041 to your computer and use it in GitHub Desktop.
  1. Create Git repo, add code, push code
  2. Enable GitHub pages.
  3. In Vue code, create new file vue.config.js with this contents. This file will be in the base directory of your project, same place as package.json. Change name-of-your-repo to the name of your GitHub repo
module.exports = {
    publicPath: process.env.NODE_ENV === 'production'
      ? '/name-of-your-repo/'
      : '/',
      outputDir: "docs"
  }
  1. Run
npm run build

A /docs directory will be created.

  1. Change into docs directory,
cd docs
  1. Make sure you are in the docs directory. Create new GitHub repo in the docs directory and add and commit all files with
git init
git add -A
git commit -m "deploy"
  1. Force push the code in the docs directory to the gh-pages branch at GitHub. Change the URL to your repository's URL.

Double-check this command before you run it, make sure you are in the docs directory, and don't miss off the master:gh-pages part!

git push -f https://github.com/your-github-account/name-of-your-repo master:gh-pages
  1. In the repository settings, go to GitHub pages section. Change the branch from master to gh-pages.
    Set or confirm the folder to be root. Click save.

  2. Wait a few minutes

  3. Your site should be at this address. Note slash at the end of the URL. https://your-github-account.github.io/name-of-your-repo/

  4. To make updates, repeat steps 4 through 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment