Hugo 架站

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

1. 安裝 Hugo

照官方文件走就好:

Installation | Hugo (gohugo.io)

2. 建立網站

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

Quick start | Hugo (gohugo.io)

3. 選 Theme

挑 theme 就像挑房子,選錯風格訪客會直接關掉。我用的是 Hugotex,再自己改了一些細節。

完整清單:Hugo Themes

4. 部署到 GitHub Pages

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

Deploying Hugo on GitHub Pages


常用指令

新增文章:

hugo new post/your-awesome-title.md

自訂 archetype 模板:

archetypes/ 建一個範本,之後新增文章自動套用:

---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
author: "Sheng"
description: ""
tags: []
keywords: []
---

用自訂模板新增文章:

hugo new --kind ../posts post/test.md