- 执行
brew install hugo
安装 hugo。 - 添加文章:在 当前路径/content/post/ 中创建目录和 md 文件,比如是 mysql-test/MySQL 测试用例详解.md。
- 执行
hugo server -D
在终端启动服务。 - 在浏览器输入
http://localhost:1313/
预览。 - 若文章无问题,在当前路径执行
hugo
构建静态网站目录public
。 - 将
public
路径下的文件挪到../
即上级目录。 - 提交到 github。
以安装 yelee 主题为例说明。
- 安装 hexo:
$ brew install hexo
- 初始化网站目录:
$ hexo init hexo # 将网站根目录选择hexo目录下
$ cd hexo
本小节插件都是后文
pure
主题所用到的。
更新 npm 版本:
$ sudo npm install -g npm
安装插件:
$ npm install hexo-wordcount --save
$ npm install hexo-generator-json-content --save
$ npm install hexo-generator-feed --save
$ npm install hexo-generator-sitemap --save
具体用法参考链接中的 README 。
$ npm install hexo-generator-baidu-sitemap --save
hexo-renderer-marked - markdown 图片插件:
$ npm install hexo-renderer-marked --save
安装后在_config.yaml
中更改配置如下:
post_asset_folder: true
marked:
prependRoot: true
postAsset: true
auto minify html、js、css and make it neat
$ npm install hexo-neat --save
You can configure this plugin in _config.yml
.
# hexo-neat
neat_enable: true
neat_html:
enable: true
exclude:
neat_css:
enable: true
exclude:
- '*.min.css'
neat_js:
enable: true
mangle: true
output:
compress:
exclude:
- '*.min.js'
$ npm install hexo-baidu-url-submit --save
translate the chinese title of Hexo blog to english words automatially
$ npm install hexo-translate-title --save
You can configure this plugin in _config.yml
.
translate_title:
translate_way: google #google | baidu | youdao
youdao_api_key: XXX
youdao_keyfrom: XXX
is_need_proxy: true #true | false
proxy_url: http://localhost:8123
hexo-renderer-markdown-it-plus
# Mathjax Support
$ npm un hexo-renderer-marked --save
$ npm i hexo-renderer-markdown-it-plus --save
You can configure this plugin in _config.yml
.
markdown_it_plus:
highlight: true
html: true
xhtmlOut: true
breaks: true
langPrefix:
linkify: true
typographer:
quotes: “”‘’
plugins:
- plugin:
name: markdown-it-katex
enable: true
- plugin:
name: markdown-it-mark
enable: false
Article enable mathjax:
title: Hello World
mathjax: true
以安装 pure 主题为例说明。
- 下载主题:
cd hexo
git submodule add https://github.com/cofess/hexo-theme-pure themes/pure
- 修改
_config.yml
文件的主题:
theme=pure
- 修改
theme/pure/_config.yml
的一些配置。 - 可按照上一小节部分来初步验证主题效果。
pure
主题在首页添加了 categories、tags、about 等一系列页面,但是并未关联到主题中,因此,需要在根目录中创建对应页面。
- 在博客所在文件夹执行:
$ hexo new page categories
INFO Validating config
INFO Created: ~/work/github/blogs-of-github/DBKernel.github.io/hexo/source/categories/index.md
- 根据上面的路径,找到
index.md
这个文件,修改为如下内容(参考themes/pure/_source/categories/index.md
):
---
title: 分类
date: 2021-07-10 17:34:18
layout: categories
comments: false
---
- 保存并关闭文件。
- 在博客所在文件夹执行:
$ hexo new page tags
INFO Validating config
INFO Created: ~/work/github/blogs-of-github/DBKernel.github.io/hexo/source/tags/index.md
- 根据上面的路径,找到 index.md 这个文件,修改为如下内容(参考
themes/pure/_source/tags/index.md
):
---
title: 标签
date: 2021-07-10 13:47:40
type: "tags"
layout: tags
comments: false
---
- 保存并关闭文件。
- 在博客所在文件夹执行:
$ hexo new page about
INFO Validating config
INFO Created: ~/work/github/blogs-of-github/DBKernel.github.io/hexo/source/about/index.md
- 根据上面的路径,找到 index.md 这个文件,修改为如下内容(参考
themes/pure/_source/about/index.md
):
---
title: 关于
date: 2021-07-10 13:47:55
type: "about"
description: 个人简介
layout: about
comments: false
sidebar: custom
---
个人说明部分。
- 保存并关闭文件。
- 在博客所在文件夹执行:
$ hexo new page links
INFO Validating config
INFO Created: ~/work/github/blogs-of-github/DBKernel.github.io/hexo/source/links/index.md
- 根据上面的路径,找到 index.md 这个文件,修改为如下内容(参考
themes/pure/_source/links/index.md
):
---
title: 友情链接
layout: links
comments: true
sidebar: none
---
个人说明部分。
- 保存并关闭文件。
- 在博客所在文件夹执行:
$ hexo new page repository
INFO Validating config
INFO Created: ~/work/github/blogs-of-github/DBKernel.github.io/hexo/source/repository/index.md
- 根据上面的路径,找到 index.md 这个文件,修改为如下内容(参考
themes/pure/_source/repository/index.md
):
---
title: 项目
layout: repository
comments: true
sidebar: none
---
个人说明部分。
- 保存并关闭文件。
- 按如下指令创建新文章后,会生成文件
source/_posts/test.md
:
hexo new "test"
- 编辑
test.md
并保存,可在 markdown 文章头添加分类、标签等标识:
---
title: test
date: 2020-12-09 11:37:10
categories:
- MySQL
tags:
- MySQL
- auto_increment
toc: true
---
- 生成页面:
hexo g
- 启动本地预览:
hexo s
3.浏览器输入http://localhost:4000
进行预览。
- 将生成的页面 copy 到
../docs/
目录。 - 推送到 github。
- 启用 github pages,设置网站路径为
/docs
。 - 在浏览器输入
dbkernel.github.io
访问网站。
见 hexo/themes 和 hugo/themes 。