Hexo使用笔记

前言

我的博客站点建好了,之前写过一篇文章了。感觉很好,有总比没有强(聊胜于无)。

但是,访问几次我的博客后,自己都感觉不好意思了。

  • 首页就把所有文章的内容都显示出来了,正常应该每篇文章只显示摘要信息吧?
  • home、archives、recent posts都是什么鬼,我们是中国人!
  • 正常博客的基本功能分类、标签、评论都去哪里了?
  • ……

既然用了hexo,就要相信他,上面这些对hexo来说都是小意思。本文会一一解决之。但是hexo毕竟只是个博客建站工具,除此别无他用,所以我计划只用这一篇文章记录hexo的使用,以后不再写相关的文章了,有需要记录的就这篇文章改吧。

下面进入hexo笔记正文。

笔记

Hexo是什么

Hexo is a fast, simple & powerful blog framework powered by Node.js
https://hexo.io/

在首页只显示每篇文章的摘要信息

方式1
在编写md文件内容时,在要显示的内容后、要隐藏的信息前加入一行<!-- more -->

方式2
在md文件的fron-matter(每篇文章的开头部分)加入一项description,其值就是文章的摘要。

开启/关闭文章评论功能

front-matter中设置comments: true/false

为文章归档

front-matter中设置categories分类、设置tags标签。
下面列出本文的front-matter

1
2
3
4
5
6
7
title: Hexo使用笔记
date: 2018-04-10 10:53:00
tags: [tag1, tag2, tag3]
categories: Hexo
comments: true
toc: true #显示文章目录
description: 使用Hexo搭建博客过程的问题笔记

怎么说好的toc、description等都不管用?换个主题试试

更改主题及语言

下载主题

1
$ git clone https://github.com/iissnan/hexo-theme-next themes/next

修改_post.yml

1
2
theme: next
language: zh_Hans #应该是去找next主题下的zh_Hans.yml

nani?评论还是不行,算了不管了,反正我也不是听人意见的人。有空参考一下https://www.zhihu.com/question/38797520这篇吧。

创建分类页、标签页

1
2
$ hexo new page categories
$ hexo new page tags

修改categories/index.md

1
2
title: 分类
type: "categories"

修改tags/index.md

1
2
title: 标签
type: "tags"

最后别忘了hexo clean & hexo g & hexo d

next主题设置头像

拷贝要当头像的图片到themes/next/source/images目录下

1
cp drogba.pn themes/next/source/images

修改themes/next/_config.yml文件

1
avatar: /images/drogba.png

next主题样式选择

修改themes/next/_config.yml文件

1
2
3
4
# Schemes
#scheme: Muse
scheme: Mist
#scheme: Pisces

next主题菜单栏显示控制

修改themes/next/_config.yml文件

1
2
3
4
5
6
menu:
home: / || home
about: /about/ || user
tags: /tags/ || tags
categories: /categories/ || th
archives: /archives/ || archive

站内搜索

安装相关插件

1
2
$ npm install hexo-generator-search --save
$ npm install hexo-generator-searchdb --save

修改站配置_config.yml

1
2
3
4
5
search:
path: search.xml
field: post
format: html
limit: 10000

修改主题配置themes/next/_config.yml

1
2
local_search:
enable: true

===

其他以后再补充

===