Hugo 模块

安装要求

在开始之前,你需要安装以下软件:

步骤

初始化新的站点

hugo new site my-site --format=yaml

通过 Hugo 模块引入主题

# 初始化Hugo模块
cd my-site
hugo mod init github.com/username/my-site

# 添加 Hugo Narrow 主题
hugo mod get github.com/tom2almighty/hugo-narrow

复制示例站点配置

hugo-narrow/exampleSite/ 下的内容复制到站点根目录下。这种方式在 ~/themes/ 目录下不会创建文件,访问主题仓库查看文件。

修改 hugo-narrow/config/_default/hugo.yaml 配置文件,通过模块引入主题:

module:
  hugoVersion:
    extended: true
    min: 0.146.0
  imports:
    - path: github.com/tom2almighty/hugo-narrow

本地预览

hugo server --buildDrafts --disableFastRender

访问 http://localhost:1313 查看预览站点。

更新主题

更新仓库中所有的模块,使用下面的命令:

hugo mod get -u

更新主题模块使用下面的命令:

hugo mod get -u github.com/tom2almighty/hugo-narrow

Note

访问 Hugo 模块 查看 Hugo 模块更新文档。