BlogByHexo

Hexo 折腾日记

​ 网上有很多的教程,这里记录一下我的折腾,然后达到自己想要的效果都做了什么

安装 nodejs、npm、git

1
2
3
sudo apt install nodejs
sudo apt install npm
sudo apt install git

起一个名为 blog 的文件夹,在该文件夹里边儿起 Hexo

1
2
3
4
5
mkdir blog
cd blog
sudo npm install -g hexo-cli
hexo init
npm install # 安装必要的plugin

_config.yml 配置,下面是我修改了的部分

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Site
title: Bencorn
subtitle: ''
description: ''
keywords:
author: shuisong
language: zh-CN
timezone: ''

# URL
## If your site is put in a subdirectory, set url as 'http://example.com/child' and root as '/child/'
url: https://blog.bencorn.com
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks

# Pagination
## Set per_page to 0 to disable pagination
per_page: 12
pagination_dir: page

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: Chic

# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
type: 'git'
repository: https://github.com/shatanyumi/shatanyumi.github.io
branch: master

安装 Hexo git 插件,添加远程 github 仓库

1
2
3
4
5
6
7
8
npm install hexo-deployer-git --save
git config --global user.name shatanyumi
git config --global user.email [email protected]
ssh-keygen -t rsa -C [email protected]
cat ~/.ssh/id_rsa.pub
# 复制该内容到github的persoal access token
ssh [email protected]
# 出现下图表示配置好了

git 图片

测试一下

​ 在不修改任何 _config.yml 的情况下,执行目录为 blog/

1
2
3
hexo g
hexo s
# ctrl + 鼠标点击 (或者输入localhost:4000)

​ 在不修改 theme 的情况下,其他的如上修改 github

1
2
3
4
heoxo c
hexo g
hexo d
# 访问 shatanyumi.github.io(自己的修改一下即可)

添加域名

修改主题

1
2
3
cd themes
git clone https://github.com/Siricee/hexo-theme-Chic.git Chic
# 修改如前边儿说的.yml文件 theme: Chic
  • 然后照着人家给出来的 DIY 文档,修改自己喜欢的就好了

写文章

  • 因为hexo是靠yml来组织的,使用之前得好好看一下官方文档,然后在写
  • 注意:操作目录 blog/
1
2
3
hexo new page tag
hexo new page about
hexo new page categories
  • 编辑 tag、categories、about,下边儿给出 tag 的 front-matter ,添加 layout:tag,about不用添加
1
2
3
4
title: tag
layout: tag
date: 2020-11-09 00:09:51
______________________________________________________________________________________________________________________________

然后写文章的时候,front-matter注意添加就好了


BlogByHexo
https://www.bencorn.com/2020/11/09/BlogByHexo/
作者
Bencorn
发布于
2020年11月9日
许可协议