安裝
hexo是基于node.js制作的一個博客工具
安裝hexo之前首先需要安裝node.js
- 官網(wǎng) :https://hexo.io/zh-cn/
sudo su
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install -g hexo-cli
npm install hexo-cli -g 速度慢,npm 的 registry 修改使用淘寶的鏡像
創(chuàng)建博客
sudo su
mkdir hexo-blog
cd hexo-blog
sudo hexo init
INFO Start blogging with Hexo!
文件夾名自定義;輸出這個INFO說明成功創(chuàng)建博客。

查看所生成的文件
這時 blog 目錄下已經(jīng)生成了關于
hexo框架的一些基礎內(nèi)容。
啟動博客
啟動:
hexo s
或者
hexo server
啟動完成之后,輸出如下:
INFO Start processing
INFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.
瀏覽器就可以訪問本地4000端口:http://localhost:4000
新建文章
hexo n "test"
或者
hexo new "test"
INFO Created: /Users/paper/Documents/paper/hexo-blog/source/_posts/test.md
cd source/_posts
ls -l
查看新建的文章
編寫文章
編寫test.md
vim, VS code, Sublime Text 等等都可以

編寫后的文章
換主題
在github搜索 'hexo-theme',找自己喜歡的主題下載下來,具體的安裝方法每個github上寫得很清楚,下載的文件一般位于 hexo-blog/themes/ 目錄下。
下載完之后,修改配置文件 hexo-blog/_config.yml:
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: even
even 修改為自己下載下來的主題名,也就是hexo-blog/themes/目錄下你下載的文件名。
Menu + Categories + Tags
修改 hexo-blog/themes/even/_config.yml
menu:
Home: /
Archives: /archives/
Categories: /categories/
Tags: /tags/
添加一些菜單項, 要 new 一下那些頁面,比如 Categories:
hexo new page categories
修改hexo-blog/source/categories/index.md 文件
---
title: categories
date: 2019-10-18 23:23:02
type: "categories"
layout: "categories"
---
修改hexo-blog/_config.yml文件
這時要注意寫layout才可以從categories菜單里查看所有categories;
# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
categories的注釋去掉
tags方法和categories一樣。
在文章里使用 Categories 和 Tags
---
title: for test.
date: 2019-10-18 22:04:52
tags: [tags1, tags2]
categories: category1
---
### test category & tag
部署到GitHub
- GitHub上創(chuàng)建一個倉庫名為:username.github.io
username一定要是GitHub的賬號 - 安裝 git 部署的插件
cnpm install --save hexo-deployer-git
- 修改配置文件
cd hexo-blog
vim _config.yml
# 最底部
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://github.com/paper00/paper00.github.io.git
branch: master
指定部署的 type, repo, branch
- 部署
hexo d
或者
hexo deploy
Username for 'https://github.com': paper00
Password for 'https://paper00@github.com': yourpassword