本文將介紹如何安裝、升級本主題,以及書寫新的文章。
安裝
從頭開始創建站點
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 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 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$ git add themes/hugo-theme-bootstrap
6$ git commit -m 'Upgrade the theme'
- 將
[version]替換為最新的版本。所有版本可以通過git tag -l | sort -rV列出。 - 你也可以直接使用
master分支以獲取最新的提交。
書寫文章
假設默認語言為
en。
1$ hugo new posts/new-post/index.md
上述命令創建了一篇英文文章,同樣的,我們也可以創建一篇簡體中文的文章:
1$ hugo new posts/new-post/index.zh-cn.md
請注意:創建的文章一般處於草稿狀態,本地預覽時,
hugo server需要指定-D參數才能預覽草稿文章。文章發佈時,需要將draft改為false,或者直接移除draft參數。
你可以將文章放在任何地方,比如
blog,只需要將blog附加到mainSections參數:mainSections = ["posts", "blog"]。
評論