Netlify 部署
Netlify 提供持续部署、全球 CDN、自动 HTTPS 等特性,是静态站点托管的热门选择。
通过 GitHub 仓库部署
Section titled “通过 GitHub 仓库部署”- 先将 Gridea Pro 配置为推送到 GitHub 仓库(参考 GitHub Pages 部署)
- 登录 Netlify,点击 Add new site > Import an existing project
- 选择 GitHub,授权并选择博客仓库
- 配置构建设置:
| 配置项 | 值 |
|---|---|
| Build command | 留空 |
| Publish directory | . |
| Branch | main(与 Gridea Pro 配置一致) |
- 点击 Deploy site
- 进入 Site settings > Domain management > Add custom domain
- 输入你的域名并验证
- Netlify 会提示你添加 DNS 记录:
- CNAME:
blog.example.com->your-site.netlify.app - 或将 Nameserver 迁移到 Netlify DNS
- CNAME:
- HTTPS 证书自动签发
404 页面配置
Section titled “404 页面配置”Gridea Pro 生成的 404.html 会被 Netlify 自动识别为自定义错误页面,无需额外配置。
在仓库根目录创建 netlify.toml 文件自定义行为:
[build] publish = "."
[[headers]] for = "/styles/*" [headers.values] Cache-Control = "public, max-age=31536000"
[[redirects]] from = "/*" to = "/404.html" status = 404Netlify 还提供表单处理和 Serverless Functions 等附加功能。虽然 Gridea Pro 生成的是纯静态站点,但你可以在主题模板中添加 Netlify Forms 来收集读者反馈:
<form name="contact" method="POST" data-netlify="true"> <input type="text" name="name" placeholder="你的名字" /> <textarea name="message" placeholder="留言内容"></textarea> <button type="submit">发送</button></form>Netlify 免费套餐
Section titled “Netlify 免费套餐”| 特性 | 限制 |
|---|---|
| 带宽 | 100 GB / 月 |
| 构建时间 | 300 分钟 / 月 |
| 站点数 | 无限 |
| HTTPS | 自动、免费 |
| 表单提交 | 100 次 / 月 |
如遇问题,请查阅常见问题。