# Hugo 架站筆記

> Hugo 架站記錄：安裝、照 Quick Start 建站、選 Hugotex 主題、用 GitHub Actions 部署到 GitHub Pages，附新增文章和自訂 archetype 的指令。

原文：https://sheng.page/posts/hugo-website-adventure/ · 發布：2024-09-10 · 作者：Sheng

大綱由 Sheng 整理，內文由 ChatGPT 填充。圖也是 ChatGPT 生的。

## 1. 安裝 Hugo

照官方文件走就好：

[Installation | Hugo (gohugo.io)](https://gohugo.io/installation/)

## 2. 建立網站

裝好之後跟著 Quick Start 操作，幾分鐘就能把骨架跑起來：

[Quick start | Hugo (gohugo.io)](https://gohugo.io/getting-started/quick-start/#explanation-of-commands)

## 3. 選 Theme

我用的是 [Hugotex](https://themes.gohugo.io/themes/hugotex/)，再自己改了一些細節。其他選項可以直接到 Hugo Themes 比較。

完整清單：[Hugo Themes](https://themes.gohugo.io/)

## 4. 部署到 GitHub Pages

網站做好就推上去。建議搭配 GitHub Actions 自動部署，push 到 `main` 就直接上線。

[Deploying Hugo on GitHub Pages](https://gohugo.io/hosting-and-deployment/hosting-on-github/)

---

## 常用指令

**新增文章：**
```bash
hugo new post/your-awesome-title.md
```

**自訂 archetype 模板：**

在 `archetypes/` 建一個範本，之後新增文章自動套用：
```markdown
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
author: "Sheng"
description: ""
tags: []
keywords: []
---
```

**用自訂模板新增文章：**
```bash
hugo new --kind ../posts post/test.md
```

## 補充筆記

- 安裝和建站照官方的 Installation 與 Quick Start 走，幾分鐘就能把骨架跑起來。
- Theme 用 Hugotex 再自己改細節，其他選項到 Hugo Themes 比較。
- 部署到 GitHub Pages 搭配 GitHub Actions，push 到 `main` 就上線。
- 在 `archetypes/` 放自訂範本，用 `hugo new --kind` 新增文章時自動套用同一組 frontmatter。

---

> Sheng 撰寫，Claude 協助文字與範例 · 列入 20260613 blog 翻新計劃，新漆未乾。