环境搭建及测试

首先安装git和nodejs环境

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
Centos
yum install git -y
yum install -y nodejs
npm config set registry https://registry.npmmirror.com
npm install -g cnpm
npm install -g hexo-cli
mkdir blog
cd blog
hexo init
npm install hexo-deployer-git --save

Ubuntu:
1 sudo apt-get install curl
2 sudo apt update
3 sudo apt install git -y
4 git
5 sudo apt-get install nodejs
6 sudo apt install npm
7 nodejs -v
8 npm install hexo-cli -g
9 npm config set registry https://registry.npmmirror.com
10 npm install hexo-cli -g
11 mkdir blog
12 cd blog/
13 hexo
14 hexo init
15 npm install hexo-deployer-git --save

测试,这里的IP是服务器的内网IP

1
hexo s -i 172.20.255.46 -p 80

然后就可以通过公网IP访问了

安装icarus主题

进入博客所在目录然后

1
git clone https://github.com/ppoffice/hexo-theme-icarus.git themes/icarus

然后在./_config.yml中修改theme

1
theme: icarus

安装运行所需依赖

1
2
3
npm install semver
npm install --save bulma-stylus@0.8.0 hexo-component-inferno@^3.1.0 hexo-renderer-inferno@^1.0.2 inferno@^8.2.3 inferno-create-element@^8.2.3
hexo s -i 172.20.255.46 -p 80

配置主题

_config.icarus.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
widgets:
# Profile widget configurations
-
# Where should the widget be placed, left sidebar or right sidebar
position: left
type: profile
# Author name
author: xxx
# Author title
author_title: CowHorse
# Author's current location
location: xxx
# URL or path to the avatar image
avatar: https://cdn.jsdelivr.net/gh/alohe/avatars/png/notion_14.png
# Whether show the rounded avatar image
avatar_rounded: false
# Email address for the Gravatar
gravatar:
# URL or path for the follow button
follow_link: https://github.com/sadqdsadsadqwd
# Links to be shown on the bottom of the profile widget
social_links:
Github:
icon: fab fa-github
url: https://github.com/sadsdqdsdqdsqdsd
RSS:
icon: fas fa-rss
url: /

添加about页面

1
hexo new page "about"

会在根目录的source文件夹下新建about/index.md

删掉不需要的配置,这三个下面的全部删掉

1
2
3
4
# Donate plugin configurations
# Share plugin configurations
# Comment plugin configurations
# Google AdSense unit configurations

配置只显示部分内容,不显示全文,在文章截断的地方加上

1
<!--more-->

widgets:配置下面的都是针对单篇文章的配置,显示目录的话,文章头部加上

1
toc: true

设置左侧栏固定

1
2
3
4
5
6
7
8
9
sidebar:
# Left sidebar configurations
left:
# Whether the sidebar sticks to the top when page scrolls
sticky: true
# Right sidebar configurations
right:
# Whether the sidebar sticks to the top when page scrolls
sticky: false

设置目录显示在哪

1
2
3
4
5
6
7
8
9
10
11
# Table of contents widget configurations
-
# Where should the widget be placed, left sidebar or right sidebar
position: left
type: toc
# Whether to show the index of each heading
index: true
# Whether to collapse sub-headings when they are out-of-view
collapsed: true
# Maximum level of headings to show (1-6)
depth: 3

加密配置

1
npm install hexo-blog-encrypt

__config.yml加上

1
2
3
4
# Security
##
encrypt:
enable: true

文章头部加上

1
2
3
password: 123
abstract: This blog is encrypted.
message: You must enter the password to read.

安装cactus主题

进入博客所在目录然后

1
git clone https://github.com/probberechts/hexo-theme-cactus.git themes/cactus

然后在./_config.yml中修改theme

1
theme: cactus

添加about页面

1
hexo new page "about"

会在根目录的source文件夹下新建about/index.md

在导航栏添加搜索功能

在./themes/cactus/_config.yml中找到nav 新建search标签

1
2
nav:
search: /search/

执行npm install hexo-generator-search –save

执行hexo new page search

进入./themes/cactus/source/serch/index.md,修改md文件的头为

1
2
3
title: Search
type: search
---

更新之后进入网站,点击search就可以搜索了

标签功能

在主题的配置文件中添加

1
2
3
4
5
6
7
8
9
10
11
12
nav:
home: /
about: /about/
articles: /archives/
tags: /tags/
projects: http://github.com/yu1e
search: /search/
title: Tags and Categories
date: 2017-12-24 23:29:53
tags:
- Foo
- Bar

然后hexo new page “tags”

在tags目录下新生成的index.md中添加

1
2
3
title: tags
date: 2024-03-31 13:59:52
type: tags

更新到github

首先生成密钥和配置用户

1
2
3
4
ssh-keygen -t rsa -C "xxx@mail.com"
cat /root/.ssh/id_rsa.pub
git config --global user.name "xxx"
git config --global user.email "xxx"

然后把公钥内容放到GitHub上,再新建一个仓库,这个就不说了,很简单

测试连接

1
ssh -T git@github.com

然后改配置文件

1
2
3
4
deploy:
type: git
repo: git@github.com:1ue0v/1ue0v.github.io.git
branch: main

更新

1
hexo g -d