把网页放进 GitHub 仓库
Put the site in GitHub
仓库负责保存网页源文件。以后你本地改完旅行手札,只要推送到主分支,Cloudflare Pages 就能自动重新发布。
GitHub stores the site files. After future edits, push to the main branch and Cloudflare Pages can publish the new version automatically.
这是一份极简操作图:先让 GitHub 承载代码,再让 Cloudflare Pages 发布网页。如果要使用个人域名,必须先注册域名,再把 DNS 托管到 Cloudflare。
A compact visual playbook: host the files on GitHub, publish them with Cloudflare Pages, then connect a custom domain after the domain is registered and delegated to Cloudflare DNS.
示意图里的账号、域名和项目名均为 mock 数据。真实操作时把它们替换成你的 GitHub 仓库、Cloudflare 项目和已注册域名。
All account names, domains, and project names below are mock data. Replace them with your GitHub repository, Cloudflare project, and registered domain.
仓库负责保存网页源文件。以后你本地改完旅行手札,只要推送到主分支,Cloudflare Pages 就能自动重新发布。
GitHub stores the site files. After future edits, push to the main branch and Cloudflare Pages can publish the new version automatically.
在 Cloudflare 里创建 Pages 项目,连接 GitHub 仓库。构建命令可以留空,输出目录填写实际网页目录。
Create a Pages project in Cloudflare and connect the GitHub repo. Leave build command empty for a static folder and set the output directory.
DNS 不用额外购买,Cloudflare Free 可以托管。但个人域名本身必须先注册。注册后在 Cloudflare 添加站点,选择 Free Plan,再把注册商 nameserver 改成 Cloudflare 给出的两条。
Cloudflare DNS is available on the Free plan, but the custom domain itself must be registered first. Add the domain to Cloudflare, choose Free, then replace registrar nameservers with the two Cloudflare nameservers.
等 Cloudflare Zone 激活后,在 Pages 项目里添加自定义域名。DNS 记录指向 Pages 二级域名,最后确认 HTTPS 和移动端访问都正常。
After the zone becomes active, add the custom domain in the Pages project. Point DNS records to the Pages subdomain, then verify HTTPS and mobile access.
真正上线前只看这四个结果:仓库可更新、Pages 可访问、域名已注册并切到 Cloudflare、HTTPS 正常。
Before calling it live, check four outcomes: repo updates work, Pages loads, the domain is registered and delegated, and HTTPS is active.
推送到 main 后会触发 Cloudflare Pages 重新部署。
Pushing to main triggers a new Cloudflare Pages deployment.
先用 Pages 免费二级域名确认公网能打开。
Use the Pages subdomain first to confirm public access.
如果域名未注册,DNS 记录不会真正生效。
If the domain is not registered, DNS records cannot go live.
nameserver 生效后再开启并检查 HTTPS。
Enable and verify HTTPS after nameservers propagate.