Time:2017-11-25
这篇blog介绍一下如何使用hugo在github page上创建个人博客
$ git clone https://github.com/username/username.github.io.git
index.html文件,这个文件将作为你github page的首页$ echo 'hello world' > index.html
$ git add .
$ git commit -m "Initial commit"
$ git push -u origin master

但这样实在是太简陋了,接下我们使用hugo来丰富一下这个blog
$ hugo new site blog
如果你想快点看到效果,也可以使用目前我使用的这个网站主题,进入到第2步创建的hugo项目中
$ mkdir themes
$ cd themes
$ git clone --depth=1 https://github.com/kishaningithub/hugo-creative-portfolio-theme.git
$ rm -rf hugo-creative-portfolio-theme/.git
$ cp -r hugo-creative-portfolio-theme/exampleSite/* ../
$ cd ..
$ hugo server

public文件夹,把username.github.io项目clone到这个hugo项目中命名为public,作为这个项目的子模块(public文件夹就是hugo生成整个静态网站)$ rm -rf public
$ git clone https://github.com/username/username.github.io.git public
username.github.io$ hugo
$ cd public
$ git add .
$ git commit -m"Used Hugo create Blog"
$ git push -u origin master
大功告成,再次访问http://username.github.io,就可以看到你的Github Page博客了(一样的,可能会有1~15分钟的延迟)
已有的文章内容是这个主题的示例在content文件夹里,你可以全部删掉或修改在content文件夹里(About和Contact也一样)
在content/portfolio 里修改或新增对应的markdown文章,然后是hugo命令生成静态站点文件在public文件里,再进入public文件夹使用git push修改到username.github.io仓库就OK了
$ bash deploy.sh,脚本内容如下hugo \
&& cd public \
&& git add . \
&& git commit -m"update `date "+DATE: %Y-%m-%d TIME: %H:%M"`" \
&& git push
$ hugo server看看blog运行是否正常,再push_config.toml中修改