使用Hexo+Github Page搭建个人博客

Hexoz中文文档

Quick Start

Github

在个人GitHub上创建名字形式为xxx.github.io的repository,并clone到本地.

基本配置

title: 名称
subtitle: 子名称
description: 描述
keywords: 关键词
author: 作者
language: 本地化(查看themes/hexo-theme-matery/languages)

更换主题

本博客使用的是hexo-theme-matery主题,在此非常感谢blinkfox的开源贡献.

  1. 下载主题
    git clone https://github.com/blinkfox/hexo-theme-matery.git themes/hexo-theme-matery
  2. 在根目录下修改_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-pluginHexo插件来做代码高亮,安装命令如下:

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

下载Hexogit插件,安装命令如下:

npm install --save hexo-deployer-git
$ hexo deploy | hexo d

上一篇
Elasticsearch(一) Docker 集群部署—单机多容器实例 Elasticsearch(一) Docker 集群部署—单机多容器实例
Elasticsearch: 6.4.2 环境:在Mac上搭建的单机多容器实例:1个master节点,一个slave节点 1. 以Docker形式安装Elasticsearch拉去镜像: docker pull docker.elast
2018-11-05
本篇
使用Hexo+Github Page搭建个人博客 使用Hexo+Github Page搭建个人博客
Hexoz中文文档 Quick StartGithub在个人GitHub上创建名字形式为xxx.github.io的repository,并clone到本地. 基本配置title: 名称 subtitle: 子名称 description:
2018-11-03
目录