GitHub + Vercel 免费部署静态博客指南
- A
文章目录 4 节
这篇博客本身就是跑在 GitHub + Vercel 上的。这里记录一下部署流程,方便日后查阅。
步骤一:推送代码到 GitHub
git initgit add .git commit -m "init: Astro blog"git branch -M maingit remote add origin https://github.com/<用户名>/<仓库名>.gitgit push -u origin main步骤二:导入 Vercel
- 登录 vercel.com,点击 New Project
- 选择 GitHub 仓库,Vercel 会自动识别 Astro 框架
- 构建配置(一般无需手动改):
| 配置项 | 值 |
|---|---|
| Framework Preset | Astro |
| Build Command | pnpm build |
| Output Directory | dist |
- 点击 Deploy,等待构建完成即可
步骤三:配置评论系统(Giscus)
- 在 GitHub 仓库 Settings → Features 开启 Discussions
- 安装 giscus app
- 到 giscus.app 生成配置,填入
src/config.ts的commentConfig - 将
commentConfig.enable改为true
以后怎么写文章
每次写好文章后:
git add src/content/posts/git commit -m "post: 新文章"git pushVercel 检测到 push 后会自动构建部署,大约 1 分钟就能上线。
正文到此结束
评论区