Hexo安装以及使用

Hexo是一款快速、简洁且高效的博客框架,通过使用Markdown语法,快速创建静态页面,并能快速部署到Github或个人服务器上,且拥有大量插件以满足各种需求。

本篇主要介绍了如何安装使用Hexo,本地平台为MacOS。

安装依赖以及Hexo

1. 安装nvm和node.js

1
2
3
brew install nvm

nvm install lts

最新更新:当前使用node版本为v22.14.0

2. 安装git

1
brea install git

3. 安装hexo

1
npm install -g hexo-cli

使用Hexo

1. 初始化hexo的工作目录

1
2
3
4
5
6
cd ~
hexo init <folder>
cd <folder>

# 一定要执行npm安装必须依赖
npm install

2. 修改配置信息_config.yml,可以设置作者、网站名字等

1
2
3
4
title: My Blog
author: LePhee
language: zh-CN
url: http://www.lephee.net

3. 安装皮肤icarus

1
2
npm install hexo-theme-icarus
hexo config theme icarus

修改_config.icarus.yml配置文件

1
2
3
4
5
6
7
8
9
10
11
12
# 图标
logo: logo.png
# 菜单栏
navbar:
menu:
首页: '/'
归档: '/archives'
分类: '/categories'
标签: '/tags'
关于: '/about'
#

配置disqus评论

1
2
3
comment:
type: disqus
shortname: 'yourshortname'

配置sharejs分享插件

1
2
share:
type: sharejs

4. 新建文章

1
hexo new "MyPost"

之后会在source/_posts/目录下创建名为MyPost.mdmarkdown文件,用该文件来写文章即可

5. 生成静态页面

1
hexo generate

6. 启动服务器

1
hexo server -p <port>

7. 打包部署

安装hexo的rsync部署工具

1
npm install hexo-deployer-rsync --save

配置rsync信息,需要有rsync权限用户

1
2
3
4
5
6
7
8
9
deploy:
type: rsync
host: ip
user: rsyncuser
root: /path/to/rsync/html
port: 1111
delete: true
verbose: true
ignore_errors: false
作者

LePhee

发布于

2018-01-07

更新于

2025-04-15

许可协议

评论