部署vuepress项目到githubPage

部署vuepress项目到githubPage

1. 项目文件夹下有两个分支(main和gh-page)

1.1 main分支存放项目代码

1.2 gh-page分支存放 npm run docs:build之后的dist里面的所有文件

2. 分别提交到github上

3. 你的项目/docs/.vuepress/config.js

复制代码
   module.exports = {
     title: 'vuePress',
     description: 'VuePress GitHub Actions',
     base: '/yt-ui-doc/', // 必须配置正确
     repo: 'https://programmermao-001.github.io/yt-ui-doc/', // 远程仓库地址
     plugins: [
   	'vuepress-plugin-mermaidjs'
     ],
     themeConfig: {
       // ...
     }
   }

4. 你的项目/deploy.sh

复制代码
   #!/usr/bin/env sh
   
   # 当发生错误时中止脚本
   set -e
   
   # 构建
   npm run build
   
   # cd 到构建输出的目录下
   cd dist
   
   # 部署到自定义域域名
   # echo 'www.example.com' > CNAME
   
   git init
   git add -A
   git commit -m 'deploy'
   
   # 部署到 https://<USERNAME>.github.io
   # git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master
   
   # 部署到 https://<USERNAME>.github.io/<REPO>
   # 将下面这行替换成自己的仓库地址
   git push -f git@github.com:ProgrammerMao-001/yt-ui-doc.git master:gh-pages   
   cd -

5. 上github.com找到自己的项目

5.1 Settings

5.2 Pages

5.3 Branch 选择 gh-page分支 / (root)文件夹

5.4 保存

6. 发布成功 例如我的

相关推荐
破烂pan1 小时前
github精选Agent学习repo
llm·github·agent
XU磊2602 小时前
Git 实现github仓库管理-删除指定目录下的所有文件并保留目录结构
git·github
逛逛GitHub9 小时前
1 天狂揽 4000 多 Star 的 AI 舆情分析开源神器。
github
卡洛斯(编程版9 小时前
大仓库推到GitHub大踩坑-Git LFS从安装到使用
git·github
玥轩_52110 小时前
Git命令速查手册
大数据·git·elasticsearch·gitee·github·命令速查
吃饺子不吃馅10 小时前
⚡️ Zustand 撤销重做利器:Zundo 实现原理深度解析
前端·javascript·github
whysqwhw11 小时前
KMP类GSON转字符串工具
github
CoderJia程序员甲12 小时前
GitHub 热榜项目 - 日榜(2025-11-06)
ai·开源·大模型·github·ai教程
诸葛思颖14 小时前
把本地 Python 项目用 Git 进行版本控制并推送到 GitHub
git·python·github
chhanz1 天前
git/github入门基操(终端版)
git·github