hexos使用的基本技巧

1、更换hexo的主题

2、新建标签、分类、归档页面

3、设置默认模板

4、将上传到github

一、更换hexo的主题

hexo默认的主题是landspace,需要更换主题,需要先到hexo官网挑选自己喜欢的主题,然后到hexo主目录下执行命令,比方说我选的是diaspora这个主题

git clone https://github.com/Fechin/hexo-theme-diaspora.git themes/diaspora

执行完命令后,在theme目录下,会新增主题相关的目录,为了令其生效,需要修改主目录下的_config.yml配置

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

把theme的参数改成diaspora

最后,执行hexo g使其生效

二、新建标签、分类、归档页面

1、用命令行新建一个页面

hexo new page tags

2、编辑配置文件/home/hexo/source/tags/index.md,设置类型type的值为”tags”

1
2
3
4
5
6
---
title: tags
date: 2021-11-23 17:42:00
type: tags
layout: tags
---

3、编辑主题目录下的_config.yml文件,取消对应的注释

1
2
3
4
5
6
menu:
首页: /
分类: /categories
标签: /tags
归档: /archives
关于: /about

4、对应关系

page type 内容
tages tages 标签
categories categories 分类
archives archives 归档
about about 关于我(自我介绍)

三、设置默认模板

编辑主目录下的scaffolds/post.md 文件

1
2
3
4
5
6
7
8
9
10
---
title: {{ title }}
date: {{ date }}
categories:
- 分类1
tags:
- 标签1
mp3: http://domain.com/awesome.mp3
cover: http://domain.com/awesome.jpg
---

四、将博客上传到github

1、创建github账户

2、新建账户仓库

创建github仓库

3、在主目录的_config.yml配置文件里,添加仓库配置

1
2
3
4
deploy:
type: git
repo: git@github.com:threebodyyouzi/threebody.github.io.git
branch: master

4、安装自动部署发布工具

npm install hexo-deployer-git --save

5、发布到github

编辑完内容后,通过hexo d将内容上传到github