Hugo + GitHub Pages + Cloudflare 免费外贸站搭建教程(2026 完整版)

一句话结论:总共花 60 块域名钱,就能搭一个 Google PageSpeed 95+ 的外贸站,一年维护费 0 元。

这套组合为什么适合外贸工厂

很多工厂老板一听建站就觉得要花大价钱、找程序员。其实 Hugo + GitHub Pages + Cloudflare 这套组合,是目前外贸独立站性价比最高的方案:

  • GitHub Pages 免费 — 不限流量,全球 CDN 加速
  • Cloudflare 免费 — 自动 SSL、更强的全球加速、防 DDoS
  • Hugo 极快 — 生成一个 1000 页的站只要几秒钟
  • SEO 友好 — Google 喜欢快的网站,Hugo 天生跑得快

整个过程分 9 步,跟着做就行。

第 1 步:买一个域名

不要用 GitHub 给的默认域名(xxx.github.io),一定要买自己的品牌域名。

推荐注册商:

  • Namesilo — 便宜,.com 约 80 元/年
  • Cloudflare Registrar — 成本价转出,免费 WhoisGuard
  • 阿里云/腾讯云 — 国内注册也方便

域名选择建议:包含产品关键词(如 chinamachineryparts.com)或工厂品牌,避免数字和连字符。

第 2 步:GitHub 账号 + 建仓库

  1. 去 github.com 注册账号
  2. 点右上角 + → New repository
  3. 仓库名必须用 你的用户名.github.io(比如 abcfactory.github.io)
  4. 选 Public,勾 Add a README file,点 Create repository

第 3 步:安装 Hugo

Windows 安装(推荐用 Chocolatey):

choco install hugo -confirm

如果没装 Chocolatey,先装一下:

Set-ExecutionPolicy Bypass -Scope Process -Force
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

验证安装:

hugo version

第 4 步:创建 Hugo 网站 + 选主题

# 新建站点
hugo new site my-website
cd my-website

# 推荐主题:PaperMod(免费、功能全、SEO 友好)
git submodule add https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod

编辑 hugo.toml 配置:

baseURL = "https://你的用户名.github.io/"
languageCode = "zh-cn"
title = "你的工厂名 - 外贸独立站"
theme = "PaperMod"

本地预览:

hugo server -D

打开 http://localhost:1313 就能看到网站了。

第 5 步:写内容

# 新建文章
hugo new posts/产品介绍.md
hugo new posts/工厂实拍.md

# 新建设备/产品目录页面
hugo new products/产品类别/index.md

内容写在 content/posts/ 目录下,用 Markdown 格式编辑。

第 6 步:部署到 GitHub Pages

# 生成静态文件
hugo

# 推送到 GitHub
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/你的用户名/你的用户名.github.io.git
git push -u origin main

GitHub → Settings → Pages → Source 选 main 分支根目录,等 1-2 分钟就能访问。

第 7 步:接入 Cloudflare(关键一步)

  1. 注册 cloudflare.com 账号(免费)
  2. 添加你的域名(比如 yourfactory.com)
  3. Cloudflare 会给两个 NS 地址,去域名注册商那边把 DNS 改成 Cloudflare 的 NS
  4. 等 DNS 生效(几分钟到几小时)

在 Cloudflare 添加 CNAME:

  • Type: CNAME / Name: @ / Target: 你的用户名.github.io / Proxy: Proxied(橙色)
  • 同样添加 www 的 CNAME

第 8 步:配置 HTTPS

Cloudflare → SSL/TLS → Overview → 选 Full (strict)。

如果报错,用 Cloudflare 给源站发证书:SSL/TLS → Origin Server → Create Certificate,下载后配置到 Nginx。

开启强制 HTTPS:SSL/TLS → Edge Certificates → Always Use HTTPS。

第 9 步:开启加速

  • Speed → Optimization → Auto Minify(JS/CSS/HTML 全勾)
  • Speed → Optimization → 开启 Brotli Compression

SEO 基础配置

Hugo 默认生成 sitemap.xml,路径 /sitemap.xml。

提交到 Google:search.google.com/search-console → 添加资源 → 验证 → 提交 sitemap。

日常更新流程

# 1. 写新文章
hugo new posts/新文章.md

# 2. 生成
hugo

# 3. 提交
git add .
git commit -m "add: 新文章"
git push

成本总结

域名 60 元/年
GitHub Pages 0 元
Cloudflare 0 元(免费版够用)
Hugo 0 元(开源)
合计 60 元/年

常见问题

Q: Hugo 会不会太技术了?
确实需要一点命令行基础,但就上面那几条命令,复制粘贴就行。实在不想碰命令行的,我们帮你用 WordPress 建站。

Q: GitHub Pages 会不会不稳定?
GitHub Pages 非常稳定,全球 CDN 加速。国内访问也还可以,如果国内客户多,可以加国内 CDN。

Q: 能不能用 Hugo 做商城?
Hugo 本身不适合做动态商城。如果需要在线下单,建议 WordPress + WooCommerce,或者 Hugo 做展示 + Shopify 嵌入。


📞 联系我们获取免费建站咨询
电话:136-2545-6232 微信:MRJ2122

原创文章,作者:小微财服云,如若转载,请注明出处:https://www.779it.com/381.html

赞 (0)
小微财服云小微财服云
上一篇 1小时前
下一篇 1小时前

相关推荐