安装
MacOS
brew install hugo
hugo new site foo/
目录结构
▸ archetypes/
▸ content/
▸ layouts/
▸ static/
config.toml
创建文章
hugo new posts/about.md
hugo new posts/article.md
主题
cd themes
git 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 public
git init
git remote add origin https://github.com/coderzh/coderzh.github.io.git
git add -A
git 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/