Git 子模块

Git 子模块

安装要求

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

步骤

初始化新的站点

hugo new site my-site --format=yaml

将 Hugo Narrow 添加为 Git 子模块

cd my-site
git init
git submodule add https://github.com/tom2almighty/hugo-narrow.git themes/hugo-narrow

复制示例站点配置

~/themes/hugo-narrow/exampleSite/ 下的内容复制到站点根目录下。

确保 ~/config/_default/hugo.yaml 中主题配置正确: theme: hugo-narrow

Note

如果你需要修改主题,将你想要修改的主题文件复制到站点根目录相同路径,在其中定义你的修改。

使用这种方式你无法提交修改到 GitHub。如果你希望保存你的修改到 GitHub 仓库,你可以 fork 主题,然后将 git submodule 添加的子模块替换成你的仓库地址。

本地预览

hugo server --buildDrafts --disableFastRender

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

更新主题

更新仓库所有子模块,使用命令:

git submodule update --remote --recursive

更新主题子模块,使用命令:

git submodule update --remote --recursive themes/hugo-narrow

Note

更多详情参阅 Git 子模块