文章目录
  1. 1. Mac下hexo从入门到精通
    1. 1.1. 需要安装什么
      1. 1.1.1. git
        1. 1.1.1.1. 如何安装git
      2. 1.1.2. node.js
      3. 1.1.3. hexo
    2. 1.2. 需要先配什么
      1. 1.2.1. 注册github/gitcafe/code.io
    3. 1.3. 配完了要干什么

Mac下hexo从入门到精通

之前玩blog的时候接触到了hexo,到现在也告一段落了,总结一下吧。
hexo到底是什么的介绍就懒得讲了。我的环境是Mac下,所以

需要安装什么

git

Mac下自带git,所以,不用安装了2333333
好吧,既然你诚心诚意的发问了。那我就稍微讲一下。

如何安装git

首先先装一个Homebrew,打开终端。

1
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

等安装完了,还差一条指令。

1
brew install git

node.js

你可以直接去下载安装包。node.js;

或者直接用brew也是可以哒。

1
brew install node

或者自先安装nvm。

1
2
git clone git://github.com/creationix/nvm.git ~/nvm
echo ". ~/.nvm/nvm.sh" >> ~/.bash_profile

关掉终端,重新打开,输入:

1
2
3
nvm install v0.10.33
nvm use v0.10.33
nvm alias default v0.10.33

后面的那个v0.10.33就是node.js的版本,目前v0.10.33是最新的。

hexo

这一步得先安装好node.js。

1
npm install -g hexo

需要先配什么

注册github/gitcafe/code.io

什么都行,总之只要提供免费主页托管的就会用起来萌萌哒。
然后,我用的是github
生成SSH KEY

1
ssh-keygen -t rsa -C "your_email@example.com"

然后将SSH KEY添加到github
登录到GitHub页面,右上角Account Settings->
SSH Public Keys->
Add another key->
将生成的key(id_rsa.pub文件)内容copy到输入框中->
save。

这个时候你在本地终端中,可以输入:

1
ssh -T git@github.com

这个时候出来一堆东西,你只要看到successful这个单词就可以确定连接成功了。

然后设置个人信息。

1
2
git config --global user.name "orifake"
git config --global user.email timyjykaka@gmail.com

然后需要创建一个项目
在自己github主页右上角,创建一个新的repository。比如账号是myname,那么应该创建的repository的名字应该是myname.github.io。

配完了要干什么

1
hexo init //选择目录,创建hexo文件夹

然后更新_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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Hexo Configuration
## Docs: http://zespia.tw/hexo/docs/configure.html
## Source: https://github.com/hexojs/hexo/
# Site 这里的配置,哪项配置反映在哪里,可以参考我的博客
title: Orifake's blog #站点名,站点banner中
subtitle: Step by step #副标题
description: orifake's Blog|hexo|javascript #给搜索引擎看的,对站点的描述,可以自定义
author: orifake #在站点左下角可以看到
email: timyjykaka@gmail.com #你的联系邮箱
language: zh-CN #中文
# URL #这项暂不配置,绑定域名后,欲创建sitemap.xml需要配置该项
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: /
root: /
permalink: :year/:month/:day/:title/
tag_dir: tags
archive_dir: archives
category_dir: categories
# Writing 文章布局、写作格式的定义,不修改
new_post_name: :title.md # File name of new posts
default_layout: post
auto_spacing: false # Add spaces between asian characters and western characters
titlecase: false # Transform title into titlecase
max_open_file: 100
filename_case: 0
highlight:
enable: true
backtick_code_block: true
line_number: true
tab_replace:
# Category & Tag
default_category: uncategorized
category_map:
tag_map:
# Archives 默认值为2,这里都修改为1,相应页面就只会列出标题,而非全文
## 2: Enable pagination
## 1: Disable pagination
## 0: Fully Disable
archive: 1
category: 1
tag: 1
# Server 不修改
## Hexo uses Connect as a server
## You can customize the logger format as defined in
## http://www.senchalabs.org/connect/logger.html
port: 4000
logger: false
logger_format:
# Date / Time format 日期格式,不修改
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: MMM D YYYY
time_format: H:mm:ss
# Pagination 每页显示文章数,可以自定义
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page
# Disqus Disqus插件,我们会替换成“多说”,不修改
disqus_shortname:
# Extensions 这里配置站点所用主题和插件
## Plugins: https://github.com/hexojs/hexo/wiki/Plugins
## Themes: https://github.com/hexojs/hexo/wiki/Themes
theme: coney
exclude_generator:
# Deployment 站点部署到github要配置
## Docs: http://zespia.tw/hexo/docs/deploy.html
deploy:
type: github
repository: https://github.com/myname/myname.github.io.git
branch: master

下面

1
2
hexo g
hexo d

就push上去了。

文章目录
  1. 1. Mac下hexo从入门到精通
    1. 1.1. 需要安装什么
      1. 1.1.1. git
        1. 1.1.1.1. 如何安装git
      2. 1.1.2. node.js
      3. 1.1.3. hexo
    2. 1.2. 需要先配什么
      1. 1.2.1. 注册github/gitcafe/code.io
    3. 1.3. 配完了要干什么