Hugo 完整教學指南 - 從零開始建立部落格
🚀 為什麼選擇 Hugo? Hugo 是一個超快速的靜態網站生成器,它的核心理念是: 你只需要寫 Markdown Hugo 自動轉換成美觀的 HTML 網站 建置速度極快(毫秒級) 不需要資料庫,純靜態檔案 📚 Hugo 的工作原理 content/ (你的 Markdown) → Hugo 處理 → public/ (生成的 HTML) 主要目錄說明 目錄 用途 需要編輯嗎? content/ 放置所有 Markdown 文章 ✅ 是 static/ 放置圖片、CSS、JS 等靜態資源 ✅ 需要時 hugo.toml 網站配置檔 ✅ 是 themes/ 主題模板 ❌ 通常不用 public/ Hugo 生成的網站 ❌ 絕對不要 archetypes/ 文章模板 🔧 偶爾 🛠️ 安裝與設定 1. 安裝 Hugo # macOS brew install hugo # Windows (使用 Chocolatey) choco install hugo-extended # Linux snap install hugo 2. 創建新網站 hugo new site myblog cd myblog 3. 安裝主題(以 PaperMod 為例) git init git submodule add --depth=1 https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod 4. 基本配置 (hugo.toml) baseURL = 'https://yourdomain.com/' languageCode = 'zh-tw' title = '我的部落格' theme = 'PaperMod' [pagination] pagerSize = 5 [params] defaultTheme = 'auto' ShowReadingTime = true ShowShareButtons = true ShowPostNavLinks = true ShowBreadCrumbs = true ShowCodeCopyButtons = true ShowWordCount = true ShowToc = true TocOpen = false ✍️ 如何新增文章 方法 1:使用 Hugo 命令(推薦) hugo new posts/my-new-post.md 方法 2:手動創建 Markdown 在 content/posts/ 目錄下創建 .md 檔案 ...