概述

Hugo是一款使用 Go 编写的静态网站生成工具,和Hexo相比最大的两个优势是:
1. 静态页面的生成速度极快 2. Hugo安装极其简单

安装 Hugo

直接下载即可使用(得益于Golang语言编译包的特性)
https://github.com/spf13/hugo/releases (版本: 0.26)
记得把执行文件加入PATH中, 推荐Windows用户使用Cmder终端.

使用 Hugo

建立站点

hugo new site /path/to/blog

创建文章

cd /path/to/blog
创建 about.md
hugo new about.md
创建其他博文
hugo new post/博文.md

挑选主题

进入 https://themes.gohugo.io/tags/blog/ 挑选自己喜欢的主题
git clone https://github.com/olOwOlo/hugo-theme-even themes/even
我使用even, 依照 https://github.com/olOwOlo/hugo-theme-even/blob/master/README-zh.md 配置. 还有参考 https://github.com/ahonn/hexo-theme-even/wiki

运行Hugo服务

hugo server --theme=even --buildDrafts
以上,theme 用于指定主题名,buildDrafts 用于运行 build 草稿,watch 用于监控文件的改动。
启动完毕后可以在浏览器中输入以下命令观察生成的站点
http://localhost:1313

部署

hugo --theme=even --baseUrl="http://michelia.github.io/"
注意,以上命令并不会生成草稿页面,如果未生成任何文章,请去掉文章头部的 draft=true 再重新生成

如果一切顺利,所有静态页面都会生成到 public 目录,将pubilc目录里所有文件 push 到刚创建的Repository的 master 分支。

https://github.com/jojomi/docker-hugo cd /e/Dev/Blog docker run -i -t –rm -P -e HUGO_WATCH=t -e HUGO_THEME=hyde-x -v e:/Dev/Blog/:/src -p 1313:1313 jojomi/hugo

http://git.bookislife.com/post/2015/how-to-use-hugo/ http://www.jianshu.com/p/bdba60260f4d

mkdir data/ layouts/ static/