0%

Hexo系列 - Next配置

由于Hexo 入门文章,写的很简单,接下来会讲如何配置Hexo 一些基本信息,如何将博客部署到 GitHub。
和Next 主题配置

版本

  • Hexo 版本:5.0.x
  • Next 版本:7.8.0

Hexo 配置

以下配置都在Hexo _config.yml 配置文件修改

网站信息

1
2
3
4
5
title: sun #网站标题
subtitle: '分享技术,记录生活' #网站副标题
description: '主要是不想做条咸鱼' #网站简介
author: sun #作者
language: zh-CN #语言

language 和主题相关 Next 7.8.0 简体中文 使用的 zh-CN 官方文档上是说使用zh-Hans 是以前的版本使用的
配置详情见 Hexo 配置

部署到 GitHub

GitHub 新建一个 repository。如果你希望你的站点能通过 <你的 GitHub 用户名>.github.io 域名访问,你的 repository 应该直接命名为 <你的 GitHub 用户名>.github.io

1
2
3
4
deploy:
type: git #类型
repo: https://github.com/<你的 GitHub 用户名>/<你的 GitHub 用户名>.github.io.git #repository
branch: master #分支

清除缓存,打包,部署

1
2
3
$ npm run clean
$ npm run build
$ npm run deploy

Next 配置

以下未说明的配置都在Next themex/next/_config.yml 配置文件修改

Schemes Next 主题

Next 提供四种主题,使用其中一种即可

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

菜单

home:首页
about:关于
tags:标签
categories:分类
archives:归档

菜单默认只打开了home archives菜单

1
2
3
4
5
6
7
8
9
menu:
home: / || fa fa-home
about: /about/ || fa fa-user
tags: /tags/ || fa fa-tags
categories: /categories/ || fa fa-th
archives: /archives/ || fa fa-archive
# schedule: /schedule/ || fa fa-calendar
# sitemap: /sitemap.xml || fa fa-sitemap
# commonweal: /404/ || fa fa-heartbeat

我们打开注释tags categories about菜单
由于这几个菜单是没有对应的文件夹,你需要执行

1
2
3
$ hexo new page "tags"
$ hexo new page "categories"
$ hexo new page "about"

会在每个文件夹下创建一个index.md文件

对应修改一下index.md文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
---
title: 标签
date: 2020-08-18 15:54:31
type: "tags"
comments: false
---

---
title: 分类
date: 2020-08-18 15:54:41
type: "categories"
comments: false
---

---
title: 关于
date: 2020-08-18 16:09:29
type: "about"
---

文件最上方以 --- 分隔的区域是Front-matter ,用于指定个别文件的变量
如果你想在文章中设置 标签tags 和分类categories 可以查看下方
更多Front-matter

侧边栏

设置侧边栏的位置,修改sidebar.position 的值,支持的选项有:

1
2
3
sidebar:
# position: left #靠左放置
position: right #靠右放置

头像

1.完整的互联网 URI,可以跳过第一步
2.站内的图片地址

第一步:将头像放置主题目录下的source/images/
第二步:修改配置文件

1
2
3
avatar:
# Replace the default image and set the url here.
url: /images/avatar.png

友情链接

links 可以添加多个

1
2
3
4
5
6
7
8
9
# 友情链接
links_settings:
icon: fa fa-link
title: 友链
# Available values: block | inline
layout: block

links:
Title: http://theme-next.iissnan.com

文章目录

设置文章目录全部展开

1
2
3
4
5
toc:
# 开关
enable: true
# 目录全部展开
expand_all: true

文章底部其他渠道

文章底部显示 欢迎关注我的其它发布渠道,例如微信公众号

1
2
3
# 关注我的其他渠道
follow_me:
WeChat: /images/wechat_channel.jpg || fab fa-weixin

代码块

代码块开启复制功能

1
2
3
4
5
6
7
8
9
10
11
12
13
#代码高亮
codeblock:
# Code Highlight theme
# Available values: normal | night | night eighties | night blue | night bright | solarized | solarized dark | galactic
# See: https://github.com/chriskempson/tomorrow-theme
highlight_theme: normal # 代码高亮样式
# Add copy button on codeblock
copy_button:
enable: true # 开启复制按钮
# Show text copy result.
show_result: true # 复制显示返回结果
# Available values: default | flat | mac
style: default # 代码块样式

顶部阅读进度

1
2
3
4
5
6
7
# 顶部阅读进度
reading_progress:
enable: true
# Available values: top | bottom
position: top
color: "#37c6c0"
height: 3px

Follow me on GitHub

右上角的GitHub 角标,打开开关,设置permalink即可

1
2
3
4
github_banner:
enable: true
permalink: https://github.com/username
title: Follow me on GitHub

欢迎关注我的其它发布渠道