Fork me on GitHub
KeKe Blog

Hexo基础

在mac上安装了hexo后的一些学习心得和总结,主要是对主配置文件(_config.yml)和hexo操作命令的一些总结,以便以后能快速回顾。
踩了很多坑,不过整体的东西还是出来了。有了框架,剩下的就慢慢添加吧!

1 Hexo安装

1
2
3
4
5
6
7
8
# 安装
npm install hexo -g
# 升级
npm update hexo -g
# 初始化,可以指定初始化的目录
hexo init "dir_name"

2 基础配置

2.1 添加标签页面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 建立标签页面
cd hexo-site
hexo new page tags
# 设置页面类型
title: 标签
date: 2016-11-29 12:12:12
type: "tags"
---
# 修改菜单,并设置该页禁用标签功能
menu:
home: /
archives: /archives
tags: /tags
comments: false

2.2 添加分类页面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 建立分类页面
cd hexo-site
hexo new page categories
# 设置页面类型
title: 分类
date: 2016-11-29 12:12:12
type: "categories"
---
# 修改菜单,并设置该页面禁用标签功能
menu:
home: /
archives: /archives
categories: /categories
comments: false

3 基础操作命令

3.1 新建文章

1
2
3
4
5
#新建文章
hexo n "article_name" == hexo new "article_name"
#草稿
hexo p "article_name" == hexo publish "article_name"

3.2 部署文章

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#清理缓存
hexo clean
#生成静态页面到public目录
hexo g == hexo generate
#启动服务预览,可以在后面添加“--debug”参数
hexo s == hexo server
#部署到github
hexo d == hexo deploy
#可以将部署简写
hexo generate --deploy
hexo deploy --generate

3.3 服务器命令

1
2
3
4
5
6
7
8
9
10
11
#Hexo监视文件变动并自动更新,无须重启
hexo server
#静态模式
hexo server -s
#更改端口
hexo server -p 5000
#自定义ip
hexo server -i 192.168.1.1
-------------本文结束 感谢您的阅读-------------