Hexo Theme

Hexo博客系统有很多的主题可供选择,跟随大潮,我同样选择了NexT主题

博客配置

Hexo博客的配置文件为_config.yml,是使用YAML语言的配置文件,不懂得可自行搜索。
这中语言的基本特点如下:

  1. YAML大小写敏感;
  2. 使用缩进代表层级关系;
  3. 缩进只能使用空格,不能使用TAB,不要求空格个数,只需要相同层级左对齐(一般2个或4个空格)

博客站点相关信息配置:

在博客根目录下找到_config.yml文件,打开,并找到Site 关键字,其下的配置为站点基本信息的配置,如下所示:

1
2
3
4
5
6
7
8
# Site
title: Ghost Cat's Blog
subtitle:
description: Ghost Cat.
keywords: Ghost Cat
author: PardonHan
language: zh-CN
timezone:

关于主题

在Hexo的官网中提供了很多收录的主题模板https://hexo.io/themes/,我选择了非常流行的NexT主题主题作为我的博客的主题模板。

主题的设置同样在根目录的 _config.yml 文件中:

1
2
3
4
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: hexo-theme-next

菜单设置

Hexo默认只有首页和归档两个菜单,创建多个菜单的教程如下。

在下载好的./themes/hexo-theme-next/主题目录中找到 _config.yml 文件(对,你没看错,就是这个文件),搜索关键字 Menu Settings ,将需要的目录取消注释。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# ---------------------------------------------------------------
# Menu Settings
# ---------------------------------------------------------------

# When running the site in a subdirectory (e.g. domain.tld/blog), remove the leading slash from link value (/archives -> archives).
# Usage: `Key: /link/ || icon`
# Key is the name of menu item. If translate for this menu will find in languages - this translate will be loaded; if not - Key name will be used. Key is case-senstive.
# Value before `||` delimeter is the target link.
# Value after `||` delimeter is the name of FontAwesome icon. If icon (with or without delimeter) is not specified, question icon will be loaded.
menu:
home: / || home
archives: /archives/ || archive
tags: /tags/ || tags
categories: /categories/ || th
about: /about/ || user
#schedule: /schedule/ || calendar
#sitemap: /sitemap.xml || sitemap
#commonweal: /404/ || heartbeat

# Enable/Disable menu icons / item badges.
menu_settings:
icons: true
badges: false

使用命令 创建对应的目录,会创建 ./source/***/index.md 文件。

1
hexo new page [tags/categories/about]

将index.md文件中的文字进行修改,例如 tags/index.md

1
2
3
4
5
6
---
title: 标签
date: 2018-07-25 09:53:49
type: "tags"
comments: false
---

在创建的文章中添加对应的标签,文章发布时会对应生成。

1
2
3
4
5
6
---
title: Why is Hexo
date: 2018-07-25 09:17:56
tags: "Blogs"
categories: "Blogs"
---