hexo使用笔记

Contents

  1. 1. 开始
  2. 2. 配置
  3. 3. 写作

折腾Otcopress时发现了hexo,主题很合我胃口,文档也很好,有中文文档,使用起来也很简单,于是就换到Hexo了。简单记录下

开始

在安装Hexo之前,必须先安装git和Node.js。

npm安装Hexo:

1
npm install hexo -g

创建项目:

1
2
hexo init project (名称可以随意)
cd project

配置

编辑根目录下的_config.yml,需要修改的几个地方。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
title: Hexo
subtitle:
description:
author: John Doe
email:
language:

url: http://yoursite.com

new_post_name: :year-:month-:day-:title.md

deploy:
type: github
repository: https://github.com/username/repo
branch: master

添加图标:

themes/light/layout/_partial/head.ejs里将<link href="<%- config.root %>favicon.png" rel="icon">替换为<link href="<%- config.root %>favicon.ico" rel="icon" type="image/x-ico">。将favicon.ico图标文件放在source目录下。制作图标的网站,www.faviconer.com

添加分享:

themes/light/layout/_partial/article.ejs中的<%-partial('post/share')%>一行删掉,替换为百度分享的代码

添加评论:

themes/light/layout/_patrial/comment.ejs中的config.disqus_shortname &&删掉, <section>内替换为多说 提供的通用代码。

写作

创建新文章:

1
hexo new "new post"

生成静态文件:

1
hexo generate

启动服务器:

1
hexo server

打开浏览器,输入http://localhost:4000 预览。

部署:

1
2
hexo deploy
hexo deploy --generate

第二个可以在部署钱自动生成文件。

移除部署文件:

1
rm -rf .deploy