Skip to content

Netlify 部署

This content is not available in your language yet.

Netlify 提供持续部署、全球 CDN、自动 HTTPS 等特性,是静态站点托管的热门选择。

  1. 先将 Gridea Pro 配置为推送到 GitHub 仓库(参考 GitHub Pages 部署
  2. 登录 Netlify,点击 Add new site > Import an existing project
  3. 选择 GitHub,授权并选择博客仓库
  4. 配置构建设置:
配置项
Build command留空
Publish directory.
Branchmain(与 Gridea Pro 配置一致)
  1. 点击 Deploy site
  1. 进入 Site settings > Domain management > Add custom domain
  2. 输入你的域名并验证
  3. Netlify 会提示你添加 DNS 记录:
    • CNAME: blog.example.com -> your-site.netlify.app
    • 或将 Nameserver 迁移到 Netlify DNS
  4. HTTPS 证书自动签发

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 = 404

Netlify 还提供表单处理和 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>
特性限制
带宽100 GB / 月
构建时间300 分钟 / 月
站点数无限
HTTPS自动、免费
表单提交100 次 / 月

如遇问题,请查阅常见问题