Cloudflare Pages + GitHub 部署博客指南

整个流程只需要三步,全程免费。

第一步:推送到 GitHub

cd my-blog
git init
git add .
git commit -m "init: 个人博客"
# 在 GitHub 上新建一个空仓库(如 my-blog),然后:
git remote add origin https://github.com/你的用户名/my-blog.git
git push -u origin main

第二步:连接 Cloudflare Pages

  1. 登录 Cloudflare Dashboard
  2. 左侧菜单 → Workers & Pages → Create → 选择 Pages 标签
  3. 选择 Connect to Git,授权并选择刚才的 my-blog 仓库
  4. 构建配置全部留空(纯静态站无需构建):
    • Framework preset: None
    • Build command: 留空
    • Build output directory: /
  5. 点击 Save and Deploy

第三步:完成

部署完成后你会得到一个 xxx.pages.dev 的免费域名。以后每次 git push,Cloudflare 都会自动重新部署,通常几十秒内生效。

可选:绑定自己的域名

在 Pages 项目的 Custom domains 里添加你的域名即可,DNS 与 HTTPS 证书 Cloudflare 全部自动搞定。