1. 什么是hugo

引用一下Hugo官网的描述

The world’s fastest framework for building websites.

Hugo是一个非常受欢迎的、开源的静态网站生成工具,和Hexo类似。 它速度快,扩展性强.

更多的关于Hugo的介绍,请参考Hugo的官网 https://gohugo.io/ .

2. 安装 hugo

从Github Release页面下载对应的二进制文件,然后把它放在你的PATH目录里即可使用。支持任何平台,根据自己的平台选择相应的二进制包即可。 github链接:https://github.com/gohugoio/hugo

#加入环境变量和执行权限
cp hugo /usr/bin/hugo
chmod +x /usr/bin/hugo

3. 使用hugo创建站点

hugo new site workerwork.github.io-site

github链接:https://github.com/workerwork/workerwork.github.io-site

4. 给站点添加主题

cd workerwork.github.io-site
git init
git submodule add https://github.com/rujews/maupassant-hugo themes/maupassant

# Edit your config.toml configuration file
# and add the maupassant theme.
echo 'theme = "maupassant"' >> config.toml

5. 配置config.toml

baseURL = "https://workerwork.github.io"
languageCode = "zh-CN"
title = "WorkSpace"
theme = "maupassant"

[author]
  name = "dongfeng"

[params]
  author = "dongfeng"
  subtitle = "专注于C、Python、Go语言(golang)、shell、项目管理、软件架构"
  keywords = "golang,go语言,go语言笔记,dongfeng,python,c,博客,项目管理,软件架构,公众号,小程序"
  description = "专注于IT互联网,包括但不限于Go语言(golang)、C、Python、项目管理、抖音分析、软件架构等"

[menu]
  [[menu.main]]
    identifier = "books"
    name = "新书"
    url = "/books/"
    weight = 2
  [[menu.main]]
    identifier = "archives"
    name = "归档"
    url = "/archives/"
    weight = 3
  [[menu.main]]
    identifier = "about"
    name = "关于"
    url = "/about/"
    weight = 4

[[params.links]]
  title = "bing搜索"
  name = "bing搜索"
  url = "https://cn.bing.com/"
[[params.links]]
  title = "baidu搜索"
  name = "baidu搜索"
  url = "http://www.baidu.com/"
[[params.links]]
  title = "千千静听"
  name = "千千静听"
  url = "http://music.taihe.com/"
[[params.links]]
  title = "git服务器"
  name = "git服务器"
  url = "http://192.168.9.105:60080"
[[params.links]]
  title = "jenkins服务器"
  name = "jenkins服务器"
  url = "http://192.168.9.105:8080"
[[params.links]]
  title = "测试jenkins服务器"
  name = "测试jenkins服务器"
  url = "http://192.168.2.115:8080"
[[params.links]]
  title = "本地网盘"
  name = "本地网盘"
  url = "http://192.168.9.105:8888"
[[params.links]]
  title = "drone服务器"
  name = "drone服务器"
  url = "http://192.168.9.105:8000"
[[params.links]]
  title = "本地蚂蚁笔记"
  name = "本地蚂蚁笔记"
  url = "http://192.168.9.105:8001"

# Valine.
# You can get your appid and appkey from https://leancloud.cn
# more info please open https://valine.js.org
[params.valine]
  enable = true
  appId = '2t4DpILldEkd0cGL96gyV1IM-gzGzoHsz'
  appKey = 'YVysijaVMqjziCECLGL8jnCh'
  notify = false  # mail notifier , https://github.com/xCss/Valine/wiki
  verify = false # Verification code
  avatar = 'mm'
  placeholder = '说点什么吧...'
  visitor = true

6. 添加评论功能组件

vim themes/maupassant/layouts/partials/comments.html
  <!-- valine -->
  {{- if .Site.Params.valine.enable -}}
  <!-- id 将作为查询条件 -->
  
  <div id="vcomments"></div>
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src='//unpkg.com/valine/dist/Valine.min.js'></script>

  <script type="text/javascript">
    new Valine({
        el: '#vcomments' ,
        appId: '{{ .Site.Params.valine.appId }}',
        appKey: '{{ .Site.Params.valine.appKey }}',
        notify: '{{ .Site.Params.valine.notify }}', 
        verify: '{{ .Site.Params.valine.verify }}', 
        avatar:'{{ .Site.Params.valine.avatar }}', 
        placeholder: '{{ .Site.Params.valine.placeholder }}',
        visitor: '{{ .Site.Params.valine.visitor }}'
    });
  </script>
  {{- end -}}

7. 合成静态页面

#运行hugo
hugo

8. 把public路径下的文件push到github上的workerwork.github.io