Hugo

go开发的静态站点生成器.

https://github.com/gohugoio/hugo

https://gohugo.io/

搭建博客

创建环境:

1
2
3
4
5
# linux
$ sudo apt-get install hugo

# windows
PATH:   C:\Hugo\bin\hugo.exe

测试安装:

1
$ hugo help

创建hugo项目:

1
2
3
$ cd /home/canux/sites
> cd C:\hugo\sites
$ hugo new site canuxcheng.com

生成下列文件和目录:

1
2
3
4
5
6
7
8
config.toml
archetypes
content    # md 文件
data
layouts
static
themes
bytes

Theme

https://github.com/gohugoio/hugoThemes

下载所有主题:

1
2
cd blog
git clone --depth 1 --recursive https://github.com/gohugoio/hugoThemes.git themes

下载单个主题:

1
2
cd themes
git clone url

在config.toml添加主题:

1
2
theme = 'name'
themesDir = "/path/to/themes"

创建主题:

1
$ hugo new theme [name]

添加自己的主题:

1
$ git submodule add https://github.com/crazy-canux/hugo-theme-canux.git

创建页面

1
2
## content/about.md
$ hugo new about.md

创建文章

1
2
## content/<category>/page.md
$ hugo new Linux/Shell.md

# 本地测试

1
2
 $ hugo server --theme=hyde --buildDrafts
 $ firefox http://localhost:1313

部署到github

先在github创建repo.

1
$ hugo --theme=<theme> --baseUrl="https://<user>.github.io/"

push到github:

1
2
3
4
5
6
$ cd public
$ git init
$ git remote add origin https://github.com/<user>/<user>.github.io.git
$ git add -A
$ git commit -m "first push."
$ git push -u origin master