VitePress 构建的博客如何部署到 github 平台?

简介: VitePress 构建的博客如何部署到 github 平台?

1. 新建 github 项目

2. 构建 VitePress 项目

2.1. 设置 config 中的 base

由于我们的项目名称为 vite-press-demo,所以我们把 base 设置为 /vite-press-demo/,需注意前后 /

export default defineConfig({
  base: '/vite-press-demo/',
  ...,
})

2.2. 页面显示异常

这个时候你发现本地页面显示异常


是因为配置了 base 之后,导致路径不正确,点击上面的链接即可

2.3. favicon 显示异常

配置好 base 之后,你发现其他页面都没问题,图片也都能正常显示,但是 favicon 不能正常显示。


只需要把 head 中配置的 icon 路径改下即可,加上 /vite-press-demo 前缀

head: [
    ['link', { rel: 'icon', href: '/vite-press-demo/extension.ico'}],
], // 加上 /vite-press-demo 前缀

2.4. 运行 pnpm run docs:build 进行项目构建

项目正常构建成功

3. 项目发布到 github 上

3.1. clone 项目,并把构建的内容发布到 main 分支

是构建之后 dist 文件夹中的内容,不包括 dist 文件夹

.
├── 404.html
├── README.md
├── api
├── assets
├── basic
├── components
├── core
├── develop.svg
├── ext-2.svg
├── ext.svg
├── extension.ico
├── hashmap.json
├── index.html
├── react.svg
├── summarize
├── teach
├── team
├── tj.svg
└── vue.svg

3.2. 部署到 github

3.2.1. 点击 Setting 按钮

3.2.2. 点击 Pages 按钮

3.2.3. 找到 Branch,并下拉选择 main 分支

3.2.4. 点击 Save 保存

3.2.5. 等...

等几分钟,一般一分钟以内
不停的刷新当前页面也行
然后就会发现当前页面多了个 Visit site 模块

3.2.6. 点击 Visit site


点击之后,就跳转到对应的网站链接啦...
我这边是这个:https://18055975947.github.io/vite-press-demo/

4. 更新项目

当文档内容需要更新的时候,在开发完成之后,重新构建完成,把 dist 文件夹中内容重新发布到 main 分支即可,剩下的就是等就行
也可以点击 Setting-> Pages 模块刷新页面
可以看到这下面有部署的时间点

二、总结

1. 项目目录

.
├── docs
│   ├── .vitepress
│   │   ├── config.mts
│   │   └── utils.ts
│   ├── api
│   │   ├── api1.md
│   │   ├── api2.md
│   │   └── index.md
│   ├── basic
│   │   ├── basic1.md
│   │   ├── basic2.md
│   │   └── index.md
│   ├── components
│   │   └── test.md
│   ├── core
│   │   ├── core1.md
│   │   ├── core2.md
│   │   └── index.md
│   ├── index.md
│   ├── public
│   │   ├── basic
│   │   │   ├── basic-desc.png
│   │   │   └── basic-popup.png
│   │   ├── develop.svg
│   │   ├── ext-2.svg
│   │   ├── ext.svg
│   │   ├── extension.ico
│   │   ├── react.svg
│   │   ├── tj.svg
│   │   └── vue.svg
│   ├── summarize
│   │   ├── index.md
│   │   ├── summarize1.md
│   │   └── summarize2.md
│   ├── teach
│   │   ├── index.md
│   │   ├── teach1.md
│   │   └── teach2.md
│   └── team
│       ├── index.md
│       ├── team1.md
│       └── team2.md
├── package.json
└── pnpm-lock.yaml

2. 项目代码

源码:【develop 分支

Demo 预览:【demo 项目预览

使用 Vitepress 构建博客https://blog.csdn.net/guoqiankunmiss/article/details/138163772

目录
相关文章
|
9天前
如何将静态网页部署到github上
如何将静态网页部署到github上
9 1
|
4天前
|
jenkins Java Shell
蓝易云 - Java+Github+Jenkins部署
以上步骤完成后,每当你的Github仓库有新的提交时,Jenkins就会自动构建你的Java项目,并保存构建产物。
15 4
|
20天前
|
Web App开发 缓存 移动开发
四万字符数带你使用 Vitepress 构建博客并部署到 github 平台
四万字符数带你使用 Vitepress 构建博客并部署到 github 平台 最近写了好多篇 Chrome 浏览器插件相关的文章,有十几二十篇,就想着构建个博客,用来放置相应的文章。 正好前段时间看到 VitePress 1.0.0 发布了,而且是用 markdown 写文章,正好写插件文章的时候文章都是 md 格式,所有用下这个然后顺便写一篇使用教程。 Chrome 插件开发博客地址:https://18055975947.github.io/extension/
32 0
|
7天前
|
JavaScript 应用服务中间件 程序员
技术人如何利用 github+Jekyll ,搭建一个独立免费的技术博客
技术人如何利用 github+Jekyll ,搭建一个独立免费的技术博客
|
网络安全 开发工具 git
使用github与Octopress 搭建GitHub Pages博客
<h3 id="section" style="line-height:32.7599983215332px; margin:0px; padding:0px; color:rgb(51,51,51); font-family:'Hiragino Sans GB W3','Hiragino Sans GB',Arial,Helvetica,simsun,u5b8bu4f53"> 前提条件
1747 0
|
1月前
|
文字识别 异构计算 Python
关于Github中开源OCR项目的实验过程与思考
新手尝试Git clone Python OCR项目,遇到各种报错。测试了Paddle OCR、Tesseract OCR和EasyOCR。Paddle OCR因平台限制未能在Notebook部署,Tesseract OCR在Colab成功但无法复现。EasyOCR最终在阿里云天池和Colab部署成功,但天池GPU资源不足。建议使用魔搭社区的实例,阿里云提供免费OCR服务。寻求简单OCR项目推荐。附EasyOCR安装和使用代码。
85 2
|
1月前
|
人工智能 自然语言处理 iOS开发
『GitHub项目圈选19』推荐5款本周 让人爱不释手 的开源项目
『GitHub项目圈选19』推荐5款本周 让人爱不释手 的开源项目
|
1月前
|
存储 Web App开发 人工智能
『GitHub项目圈选18』推荐5款本周 超实用 的开源项目
『GitHub项目圈选18』推荐5款本周 超实用 的开源项目
249 1
|
1月前
|
人工智能 物联网 机器人
『GitHub项目圈选17』推荐5款本周 火火火 的AI开源项目
『GitHub项目圈选17』推荐5款本周 火火火 的AI开源项目
618 1
|
1月前
|
前端开发
Github项目分享——免费的画图工具drow,最新前端面试题整理
Github项目分享——免费的画图工具drow,最新前端面试题整理