简单使用Hexo安装与主题配置使用教程

Hexo安装与主题配置使用教程

一、Hexo安装

1. 安装Hexo命令行工具

1
npm install hexo-cli -g

2.初始化Hexo站点

1
hexo init blog

进入站点目录:

1
cd blog

3.启动本地服务器

1
hexo server

访问http://localhost:4000即可查看博客。

二、主题安装与配置

1.安装主题

1
2
3
git clone https://github.com/tufu9441/maupassant-hexo.git themes/maupassant
npm install hexo-renderer-pug --save
npm install hexo-renderer-sass-next --save

2.配置主题

全局配置文件_config.yml

1
2
theme: maupassant
language: zh-CN

主题配置文件_config.yml
在主题目录themes/maupassant/_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
disqus:
enable: true
shortname: your_disqus_shortname

google_search: true

menu:
- page: home
directory: .
icon: fa-home
- page: about
directory: about/
icon: fa-user

widgets:
- search
- recent_posts
- links

info:
avatar: /img/avatar.png
description: This is my personal blog.
outlinkitem:
- name: github
outlink: https://github.com/your_github_username
message: My GitHub

copycode: true

三、生成与部署

1.生成静态文件

1
hexo generate

2.部署到远程服务器

安装部署插件(以部署到GitHub Pages为例)

1
npm install hexo-deployer-git --save

_config.yml文件中配置部署信息

1
2
3
4
deploy:
type: git
repo: https://github.com/your_github_username/your_github_repo.git
branch: main

运行以下命令进行部署

1
hexo deploy

通过以上步骤,你就可以成功安装并配置Hexo及其主题,创建并部署自己的个人博客了。