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

创建项目

  1. hugo new howie /path/howie //创建项目howie,/path/howie为路径
  2. 进入 /path/howie 目录
  3. 结构为
  4. archetypes/
  5. content/
  6. layouts/
  7. static/
  8. config.toml

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

  1. hugo new post/first.md

打开编辑 post/first.md :

  1. ---
  2. date: "2018-10-12"
  3. title: "first"
  4. ---
  5. testtesttesttesttesttest

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

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

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

  1. ---
  2. date: 2018-10-11
  3. title: "我的博客是如何构建的"
  4. description: "我的博客是如何构建的"
  5. tags: ["其他", "golang"]
  6. categories: ["其他"]
  7. ---

启动

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

配置

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

  1. baseurl = "http://hwholiday.github.io/"
  2. title = "Howie"
  3. languageCode = "en-us"
  4. theme = "LeaveIt"
  5. paginate = 12
  6. enableEmoji = true
  7. enableRobotsTXT = true
  8. preserveTaxonomyNames = true
  9. [blackfriday]
  10. hrefTargetBlank = true
  11. nofollowLinks = true
  12. noreferrerLinks = true
  13. [params]
  14. since = 2017
  15. author = "Howie"
  16. avatar = "头像地址"
  17. subtitle = "坚信自己会更好"
  18. [Permalinks]
  19. posts = "/:year/:filename/"
  20. [menu]
  21. [[menu.main]]
  22. name = "主页"
  23. url = "/posts/"
  24. weight = 1
  25. [[menu.main]]
  26. name = "分类"
  27. url = "/categories/"
  28. weight = 2
  29. [[menu.main]]
  30. name = "标签"
  31. url = "/tags/"
  32. weight = 3
  33. [[menu.main]]
  34. name = "关于"
  35. url = "/about/"
  36. weight = 4
  37. [params.social]
  38. GitHub = "hwholiday"
  39. Email = "地址"
  40. Wechat = "地址" # Wechat QRcode image

发布项目到github

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

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

进入项目里面的pubilc文件夹

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

设置默认为黑色

  1. vim /themes/LeaveIt/layouts/_default/baseof.html
  2. 修改为
  3. <!DOCTYPE html>
  4. <html lang="{{ .Site.LanguageCode }}">
  5. {{ partial "head.html" . }}
  6. <body class="dark-theme">
  7. <div class="wrapper">
  8. {{ partial "header" . }}
  9. <main class="main">
  10. <div class="container">
  11. {{ block "content" . }}{{ end }}
  12. </div>
  13. </main>
  14. {{ partial "footer.html" . }}
  15. </div>
  16. </body>
  17. </html>

联系 QQ: 3355168235