Quick Start
Github
在个人GitHub
上创建名字形式为xxx.github.io
的repository,并clone到本地.
基本配置
title: 名称
subtitle: 子名称
description: 描述
keywords: 关键词
author: 作者
language: 本地化(查看themes/hexo-theme-matery/languages)
更换主题
本博客使用的是hexo-theme-matery
主题,在此非常感谢blinkfox
的开源贡献.
- 下载主题
git clone https://github.com/blinkfox/hexo-theme-matery.git themes/hexo-theme-matery
- 在根目录下修改
_config.yml
文件theme: hexo-theme-matery
新建categories
categories
页是用来展示所有分类的页面,如果在你的博客source
目录下还没有categories/index.md
文件,使用如下命令创建:
$ hexo new page "categories"
编辑你刚刚新建的页面文件/source/categories/index.md
,添加以下内容:
---
title: 分类
date: 2018-11-03 15:32:23
type: "categories"
layout: "categories"
---
新建tags
tags
页是用来展示所有标签的页面,如果在你的博客source
目录下还没有tags/index.md
文件,使用如下命令创建:
$ hexo new page "tags"
编辑你刚刚新建的页面文件/source/tags/index.md
,添加以下内容:
---
title: 标签
date: 2018-11-03 14:45:54
type: "tags"
layout: "tags"
---
新建about
about
页是用来展示关于我和我的博客信息的页面,如果在你的博客source
目录下还没有about/index.md
文件,使用如下命令创建:
$ hexo new page "about"
编辑你刚刚新建的页面文件/source/about/index.md
,添加以下内容:
---
title: about
date: 2018-11-03 15:48:12
type: "about"
layout: "about"
---
代码高亮
由于Hexo默认的高亮主题不好用,所以我使用了hexo-prism-plugin
的Hexo
插件来做代码高亮,安装命令如下:
npm install hexo-prism-plugin --save
然后修改根目录下的_config.yml
文件,修改如下:
highlight:
enable: false
prism_plugin:
mode: 'preprocess' # realtime/preprocess
theme: 'tomorrow'
line_number: false # default false
custom_css:
站内搜索
使用Hexo
插件hexo-generator-search
来做站内搜素,安装命令如下:
npm install hexo-generator-search --save
然后修改根目录下的_config.yml
文件,修改如下:
search:
path: search.json
field: post
添加RSS订阅支持
使用Hexo
插件hexo-generator-feed
,安装命令如下:
npm install hexo-generator-feed --save
然后修改根目录下的_config.yml
文件,修改如下:
feed:
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: ' '
order_by: -date
修改社交链接
修改themes/hexo-theme-matery/layout/social-link.ejs
,将社交链接改成自己的相关信息即可.
文章的Front-matter示例
---
title: Hexo
date: 2018-09-07 09:25:00
top: true # 如果top值为true,则会是首页推荐文章
categories: 随笔
tags:
- Hexo
- Markdown
---
本地运行
运行前先在根目录下执行命令npm install
$ hexo server | hexo s
生成静态文件
$ hexo generate | hexo g
部署
请先在Github配置SSH key,然后在根目录的_config.yml
文件中进行如下的配置:
deploy:
type: git
repo: 个人博客在GitHub上的repository,如 git@github.com:xxx/xxx.github.io.git
branch: master
下载Hexo
的git
插件,安装命令如下:
npm install --save hexo-deployer-git
$ hexo deploy | hexo d