准备工作

-1. gitHub

-1.1 注册gitHub帐号

-1.2 建一个同名repository,eg: hiwanglong

-1.3 建SSH-key

-1.4 windows下载gitbash工具

-2. Hugo:

download hugo.exe if windows (https://gohugo.io/)

https://github.com/gohugoio/hugo/releases

生成站点

-1 cd /path/to/site (Hugo目录下的site)

hugo new site Mysite

-2 cd /path/to/site/Mysite,目录结构如下

▸ archetypes/
▸ content/
▸ layouts/
▸ static/
  config.toml

-3 下载皮肤, cd /path/to/site/Mysite/themes

git clone https://github.com/kakawait/hugo-tranquilpeak-theme.git

-4 安装皮肤

rename hugo-tranquilpeak-theme to tranquilpeak
cp /path/to/site/Mysite/themes/tranquilpeak/exampleSite/config.toml to /path/to/site/Mysite
update config.toml
    theme = "hugo-tranquilpeak-theme" --> theme = "tranquilpeak"
    baseurl = "" --> baseurl = "https://hiwanglong.github.io/" 

-5 创建文章 cd /path/to/site/Mysite

about.md 自动生成到了 content/about.md

hugo new about.md 

first.md 自动生成到了 content/post/first.md

hugo new post/first.md 

-6. 运行Hugo并调试

hugo server --theme=tranquilpeak --buildDrafts --watch

浏览器里打开:http://127.0.0.1:1313

–watch或者-w 选项打开的话,将会监控到文章的改动从而自动去刷新浏览器,不需要自己手工去刷新浏览器,非常方便。

部署

-1. Hugo 命令生成最终页面

hugo --theme=tranquilpeak --baseUrl="https://hiwanglong.github.io/"

如果一切顺利,所有静态页面都会生成到 public 目录

-2. 发布到gitHub上,cd path/to/site/Mysite/public

git init
_hiwanglong.github.io.git
git add -A
git commit -m "first commit"
git push -u origin master

参考文档

https://blog.coderzh.com/2015/08/29/hugo/

https://themes.gohugo.io/hugo-tranquilpeak-theme/