Skip to main content
  1. Home/
  2. Posts/

Building a Personal Site with Hugo and Dual-Stack CDN

··657 words· 4 min·
One Hugo artifact is published to both Alibaba Cloud OSS/CDN and Cloudflare Pages, while geo-aware DNS sends domestic and international visitors to different edge networks.

Why Hugo
#

When picking a framework for a personal blog, my top criterion was low maintenance cost — I didn’t want to abandon writing three months later because of npm dependency hell.

Hugo is a single binary, requires no Node.js, builds thousands of posts in 1-2 seconds, and the Blowfish theme comes with dark mode, full-text search, multilingual support, RSS, Open Graph, and reading time estimates out of the box. Day-to-day writing only requires touching Markdown files.

Architecture
#

The diagram contains two distinct flows. Read downward from Git Push for the publishing path; read from GeoDNS toward the two CDNs for the request path. Both destinations must come from the same build to prevent content-version drift.

A dual-stack Hugo deployment across Alibaba Cloud and Cloudflare
Dual-CDN publishing: GitHub Actions builds once, then uploads the same artifact to Alibaba Cloud OSS/CDN and Cloudflare Pages. GeoDNS selects the visitor path while the content commit stays identical.

Annual cost: approximately ¥212 (~$30 USD):

  • Domain zhuoqidev.com: ¥85/yr (bought 3 years)
  • Function Compute resource pack (ICP filing): ¥101/yr (¥126 annual pack with 20% ongoing discount)
  • Alibaba CDN 100GB traffic pack: ¥20/yr
  • OSS storage: ~¥6/yr
  • Cloudflare Pages: ¥0

ICP Filing Without a Server
#

Websites served to mainland China visitors need an ICP filing, which requires a “filing carrier” (a server IP). Instead of buying a full server, Alibaba Cloud’s Function Compute resource pack (¥101/yr) works as a filing carrier and provides a filing service code.

Timeline: Alibaba Cloud initial review 1-5 working days + MIIT review 10-20 business days, about 3-6 weeks total. Plenty of time to finish the site while waiting.

Geo-DNS Routing
#

Alibaba Cloud DNS free tier supports “domestic / international” split routing:

  • Domestic → Alibaba CDN CNAME
  • International (default) → Cloudflare Pages CNAME

Domestic visitors get the ICP-compliant Alibaba CDN; international visitors get Cloudflare’s free global CDN — one domain, two acceleration paths.

Deployment
#

Push to GitHub → Actions runs hugo build → uploads in parallel to OSS and Cloudflare Pages. The whole process takes 2-3 minutes. Publishing a post is nearly instant.

A Later Addition: an Image Viewer for 4K Architecture Diagrams
#

Architecture diagrams in technical posts often contain small labels. Blowfish’s built-in medium-zoom only enlarges an image to fit the screen and closes it on the next click. Even when the source is 4K, readers cannot keep zooming by percentage or pan across the details, so I replaced it with a site-wide image viewer.

The implementation adds no new frontend dependency. The built-in zoom is disabled in hugo.yaml, while assets/js/image-viewer.js and its CSS are added to the Hugo Pipes asset pipeline. Hugo minifies and fingerprints them during the build, then the same static artifact is published to both CDNs. The script only attaches to .article-content img:not(.nozoom), so article illustrations open in the viewer without hijacking avatars, icons, or card thumbnails.

On open, the viewer calculates a fit-to-screen scale from the viewport and the image’s natural dimensions. Wheel and button zooming preserve the point under the cursor, so the detail being inspected stays in place. A zoomed image can be dragged within bounded edges. Pointer Events track two contacts for pinch zoom on touch devices, while the keyboard supports +, -, arrow keys, 0 for fit, 1 for actual size, and Esc. A click on either the image or the surrounding empty space also closes the viewer, while movement beyond the drag threshold prevents accidental dismissal. The toolbar reports the live percentage and switches its labels with the article language.

You can try it by clicking any 4K diagram in the Codex Agent design deep dive. It is also a useful property of a static site: richer interaction remains cacheable JavaScript and CSS, so the dual-CDN publishing topology does not need to change.


Upcoming posts will dive into Agent architecture design, memory layer selection, and multi-agent orchestration.

Liu ZhuoQi
Author
Liu ZhuoQi
AI 应用开发工程师(Agent 方向)。使用 Go、Python 与 React 将 Agent 能力做进真实产品,记录从开发、测试到生产交付的实践。

Related

用 Hugo 和双栈 CDN 搭建个人网站

··152 字· 1 分钟
同一份 Hugo 静态产物,同时发布到阿里云 OSS/CDN 与 Cloudflare Pages,再由 DNS 分线路把国内外访问导向不同边缘网络。 为什么选 Hugo # 做个人博客选框架,我的第一标准是维护成本低——不想三个月后因为 npm 依赖地狱放弃写作。 Hugo 是单二进制文件,无需 Node.js,构建几千篇文章只需 1-2 秒,Blowfish 主题开箱就有暗色模式、全文搜索、多语言、RSS、Open Graph、阅读时间估算。日常写作只需碰 Markdown。 整体架构 # 这张图同时画出两条不同的路径:从 Git Push 向下看是发布路径,国内外访客经 GeoDNS 进入各自 CDN 则是请求路径。两边必须来自同一次构建,才能避免内容版本漂移。 Hugo 双栈发布:GitHub Actions 只构建一次,产物分别上传到阿里云 OSS/CDN 与 Cloudflare Pages;GeoDNS 决定用户走哪条访问路径,而提交版本保持一致。 这套方案全年花费约 ¥212:

Embedding CSS Animation Demos in Hugo Articles

··144 words· 1 min
Hugo shortcodes make it easy to embed live code demos. Here are three ways: The diagram first separates their boundaries: a native shortcode, a CodePen iframe, and a CodeSandbox app serve different complexity levels and execute code in different places. Three embed paths: prefer a native shortcode for simple, versioned effects; CodePen for shareable snippets; and CodeSandbox for a complete interactive application. 1. Inline CSS Demo (No External Service) # A spinning loader animation, right in the article:

在 Hugo 文章里内嵌 CSS 动画 Demo

··63 字· 1 分钟
Hugo 用 shortcode 可以很优雅地内嵌代码演示。这里展示三种方式: 先用一张图确定边界:原生 shortcode、CodePen iframe 和 CodeSandbox 分别适合不同复杂度,也把代码放在不同的执行与隔离位置。 三条嵌入路径:简单且需要版本控制的效果优先用原生 shortcode;可分享片段适合 CodePen;完整交互应用再使用 CodeSandbox。 1. 内联 CSS demo(无需外部服务) # 直接在文章里跑一个旋转加载动画: 纯 CSS 旋转加载器 一个渐变色文字动画: