安装
MacOS
brew install hugo
hugo new site foo/
目录结构
▸ archetypes/▸ content/▸ layouts/▸ static/config.toml
创建文章
hugo new posts/about.mdhugo new posts/article.md
主题
cd themesgit clone https://github.com/spf13/hyde.git
本地运行测试
hugo server -D --theme=hyde --buildDrafts
部署
去掉文章头部的draft=true,执行以下命令会生成public目录。
hugo -D --theme=hyde --baseUrl="https://luning.wang"
推到Git上
cd publicgit initgit remote add origin https://github.com/coderzh/coderzh.github.io.gitgit add -Agit commit -m "first commit"git push -u origin master
配置
baseURL = "https://blog.luning.wang/"languageCode = "en-us"title = "天问"[params]description = "个人博客
单篇文章配置
---# 常用定义title: "An Example Post" # 标题date: 2018-01-01T16:01:23+08:00 # 创建时间lastmod: 2018-01-02T16:01:23+08:00 # 最后修改时间draft: false # 是否是草稿?tags: ["tag-1", "tag-2", "tag-3"] # 标签categories: ["index"] # 分类author: "xianmin" # 作者# 用户自定义# 你可以选择 关闭(false) 或者 打开(true) 以下选项comment: false # 关闭评论toc: false # 关闭文章目录# 你同样可以自定义文章的版权规则contentCopyright: '<a rel="license noopener" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank">CC BY-NC-ND 4.0</a>'reward: false # 关闭打赏mathjax: true # 打开 mathjax---
Git管理博客实践
基本方法:dev分支存原始项目文件,master分支存public目录文件。
.gitignore
public/
