安装hugo(需要先安装go,git环境)

创建项目

hugo new howie /path/howie     //创建项目howie,/path/howie为路径

     进入 /path/howie 目录
     结构为
        ▸ archetypes/
        ▸ content/
        ▸ layouts/
        ▸ static/
        config.toml

创建第一篇文章,放到 post 目录,方便之后生成聚合页面。

hugo new post/first.md

打开编辑 post/first.md :

---
date: "2018-10-12"
title: "first"
---
testtesttesttesttesttest

安装皮肤这里以(Leaveit)为例子

cd themes
git clone https://github.com/liuzc/LeaveIt.git

为了更好的使用该主题我们将post/first.md的头部改为

---
date: 2018-10-11
title: "我的博客是如何构建的"
description: "我的博客是如何构建的"
tags: ["其他", "golang"]
categories: ["其他"]
---

启动

hugo server --theme=LeaveIt  --buildDrafts
浏览器里打开: http://localhost:1313

配置

根据主题配置分享下我的配置

baseurl = "http://hwholiday.github.io/"
title = "Howie"
languageCode = "en-us"
theme = "LeaveIt"

paginate = 12
enableEmoji = true
enableRobotsTXT = true


preserveTaxonomyNames = true

[blackfriday]
  hrefTargetBlank = true
  nofollowLinks = true
  noreferrerLinks = true

[params]
    since = 2017
    author = "Howie"                         
    avatar = "头像地址"           
    subtitle = "坚信自己会更好"   
[Permalinks]
 posts = "/:year/:filename/"      
[menu]
  [[menu.main]]
    name = "主页"
    url = "/posts/"
    weight = 1
  [[menu.main]]
    name = "分类"
    url = "/categories/"
    weight = 2
  [[menu.main]]
    name = "标签"
    url = "/tags/"
    weight = 3
  [[menu.main]]
    name = "关于"
    url = "/about/"
    weight = 4

[params.social]
    GitHub = "hwholiday"
    Email   = "地址"
    Wechat = "地址"  # Wechat QRcode image

发布项目到github

先在自己的github上建立一个新的项目名称为(你的github用户名.github.io)
打包项目

    hugo --theme=LeaveIt --buildDrafts --baseUrl="https://hwholiday.github.io/" 

进入项目里面的pubilc文件夹

    git init
    git add .
    git commit -m "first commit"
    git remote add origin https://github.com/hwholiday/hwholiday.github.io.git 
    git push -u origin master
    浏览器里访问:http://hwholiday.github.io/

设置默认为黑色

   vim /themes/LeaveIt/layouts/_default/baseof.html
   修改为
   <!DOCTYPE html>
   <html lang="{{ .Site.LanguageCode }}">
  {{ partial "head.html" . }}
  <body class="dark-theme">
    <div class="wrapper">
        {{ partial "header" . }}
       <main class="main">
          <div class="container">
          {{ block "content" . }}{{ end }}
          </div>
       </main>
      {{ partial "footer.html" . }}
     </div>
  </body>
</html>

联系 QQ: 3355168235