安装Hugo并建立站点
按以下步骤建立站点blog并使用飞雪无情maupassant主题(感谢),在开浏览器中输入http://localhost:1313查看新创建站点。
1
2
3
4
5
6
7
8
9
|
brew install hugo
hugo new site blog
cd blog
git init
git clone https://github.com/rujews/maupassant-hugo themes/maupassant
hugo new post/my-first-post.md
hugo server -D
|
自定义菜单
在config.toml配置文件中新增:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[menu]
[[menu.main]]
identifier = "research"
name = "研究"
url = "/research/"
weight = 2
[[menu.main]]
identifier = "archives"
name = "归档"
url = "/archives/"
weight = 3
[[menu.main]]
identifier = "about"
name = "关于"
url = "/about/"
weight = 4
|
增加文章归档支持
新建content/archives/index.md文件,内容如下:
1
2
3
|
title: "归档"
description: 文章归档
type: archives
|
永久链接
在每篇文章里的Front Matter加上:
url: /yyyy/mm/dd/post-title.html
大小写问题
为保持原来的大小写,而不自动转小写,可在config.toml配置文件中新增:
preserveTaxonomyNames = true
disablePathToLower = true
文章转移
将原Hexo文章(Markdown格式)转移至/content/post/文件夹,相关插图转移至/static/文件夹下,图片引用格式为:
1
|

|
新建GitHub Pages
新建GitHub仓库hcgu.github.io,不要初始化,地址为git@github.com:hcgu/hcgu.github.io.git。在public文件夹内:
1
2
|
git init
git remote add origin git@github.com:hcgu/hcgu.github.io.git
|
生成静态页并发布
在blog目录下使用命令hugo生产静态页,存储于public文件夹,进入该文件夹:
1
2
3
|
git add .
git commit -m "Updated at $(date)."
git push -u origin master
|