This article refers to the traditional installation method of cloning the theme locally as Git submodule. It describes how to install, upgrade the theme, and write new articles. While this installation method is still widely used, we recommend to install the theme as Hugo module.

安裝#

從頭開始創建站點#

1$ hugo new site myblog
2$ cd myblog
3$ git init
4$ git submodule add https://github.com/razonyang/hugo-theme-bootstrap themes/hugo-theme-bootstrap
5$ cp -a themes/hugo-theme-bootstrap/exampleSite/* .
6$ hugo mod npm pack
7$ npm install
8$ hugo server

如果你使用的是 Windows,請改用 xcopy .\themes\hugo-theme-bootstrap\exampleSite /E

安裝到已有站點#

 1$ cd myblog
 2$ git submodule add https://github.com/razonyang/hugo-theme-bootstrap themes/hugo-theme-bootstrap
 3$ mkdir config
 4$ cp -a themes/hugo-theme-bootstrap/exampleSite/config/* ./config
 5$ cp -r themes/hugo-theme-bootstrap/exampleSite/content/about/ \
 6  themes/hugo-theme-bootstrap/exampleSite/content/archives/ \
 7  themes/hugo-theme-bootstrap/exampleSite/content/categories/ \
 8  themes/hugo-theme-bootstrap/exampleSite/content/contact/ \
 9  themes/hugo-theme-bootstrap/exampleSite/content/offline/ \
10  themes/hugo-theme-bootstrap/exampleSite/content/search/ \
11  themes/hugo-theme-bootstrap/exampleSite/content/series/ \
12  themes/hugo-theme-bootstrap/exampleSite/content/tags/ \
13  ./content
14$ hugo mod npm pack
15$ npm install
16$ hugo server

如果你重新尅隆倉庫,你將需要通過 git submodule update --init --recursive 更新 submodule,或者 git clone --recursive <repo>

升級#

1$ cd themes/hugo-theme-bootstrap
2$ git fetch
3$ git checkout [version]
4$ cd ../../
5$ hugo mod npm pack
6$ git add themes/hugo-theme-bootstrap package.json
7$ git commit -m 'Upgrade the theme'
  • [version] 替換為最新的版本。所有版本可以通過 git tag -l | sort -rV 列出。
  • 你也可以直接使用 master 分支以獲取最新的提交。