在 Cloudflare Pages 上替 Hugo 接 Decap CMS
Hugo 很快也很彈性,但直接改 Markdown 不是每個人都喜歡。Decap CMS(前身 Netlify CMS)可以直接當靜態頁面放在 repo 裡,透過 GitHub API 讀寫 Markdown,不需要額外的 backend server。 以下是這個站實際使用的架構與設定。 架構 瀏覽器 → /shs/(Decap CMS SPA) ↓ GitHub OAuth Cloudflare Pages Function(/api/auth, /api/auth/callback) ↓ GitHub API content/posts/*.{zh,en}.md ↓ git push Cloudflare Pages build(hugo --minify) ↓ public/ → 你的 domain 沒有資料庫、沒有 CMS server,全部在 Git 裡。 1. 放 CMS 到 static 資料夾 建兩個檔案: static/shs/index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Content Manager</title> </head> <body> <script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script> </body> </html> static/shs/config.yml ...