1. 安装

在ubuntu 24.04下,安装命令如下:

# Linux (Snap)
sudo snap install hugo

2. 创建博客 newbook

$ hugo new site newbook
Congratulations! Your new Hugo site was created in /home/zhang/newbook.

Just a few more steps...

1. Change the current directory to /home/zhang/newbook.
2. Create or install a theme:
   - Create a new theme with the command "hugo new theme <THEMENAME>"
   - Or, install a theme from https://themes.gohugo.io/
3. Edit hugo.toml, setting the "theme" property to the theme name.
4. Create new content with the command "hugo new content <SECTIONNAME>/<FILENAME>.<FORMAT>".
5. Start the embedded web server with the command "hugo server --buildDrafts".

See documentation at https://gohugo.io/.

3. 设置主题

1). 将 Ananke 主题克隆到 themes 目录中,并将其作为 Git 子模块添加到项目中。

git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke

2). 在站点配置文件中追加一行,指示当前主题。

echo "theme = 'ananke'" >> hugo.toml

4. 创建内容

$ hugo  new helloword.md
Content "/home/zhang/newbook/content/helloword.md" created

默认已经添加了如下内容:

+++
date = '2025-03-27T00:43:43Z'
draft = true
title = 'Helloword'
+++

包含创作日期时间以及标题。在+++后面添加自己的内容。

5. 启动预览

hugo  server --bind 0.0.0.0

总结

hugo 比较简单易用,可以快速创建一个静态博客。

缺点:需要依赖于主题,需要选择及下载主题。