hexo操作指南-常用命令

hexo

1
2
3
npm install hexo -g #安装  
npm update hexo -g #升级
hexo init #初始化

简写

1
2
3
4
5
hexo n "我的博客" == hexo new "我的博客" #新建文章
hexo p == hexo publish
hexo g == hexo generate#生成
hexo s == hexo server #启动服务预览
hexo d == hexo deploy#部署

本地服务

1
2
3
4
5
6
7
8
hexo server #Hexo 会监视文件变动并自动更新,您无须重启服务器。
hexo server -s #静态模式
hexo server -p 5000 #更改端口
hexo server -i 192.168.1.1 #自定义 IP

hexo clean #清除缓存 网页正常情况下可以忽略此条命令
hexo g #生成静态网页
hexo d #开始部署

监视文件变动

1
2
hexo generate #使用 Hexo 生成静态文件快速而且简单
hexo generate --watch #监视文件变动

生成草稿

1
hexo publish [layout] <title>

模版

1
2
3
4
5
6
7
8
9
hexo new "postName" #新建文章
hexo new page "pageName" #新建页面
hexo generate #生成静态页面至public目录
hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server)
hexo deploy #将.deploy目录部署到GitHub

hexo new [layout] <title>
hexo new photo "My Gallery"
hexo new "Hello World" --lang tw
变量 描述
layout 布局
title 标题
date 文件建立日期
1
2
3
4
5
6
7
8
title: 使用Hexo搭建个人博客
layout: post
date: 2014-03-03 19:07:43
comments: true
categories: Blog
tags: [Hexo]
keywords: Hexo, Blog
description: 生命在于折腾,又把博客折腾到Hexo了。给Hexo点赞。

模版(Scaffold)

1
hexo new photo "My Gallery"

设置文章摘要

,以下是余下全文
1
2

### 写作

hexo new page <br>hexo new post <title><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">| 变量 | 描述 |</span><br><span class="line">| -------------|:-------------:|</span><br><span class="line">| :title | 标题 |</span><br><span class="line">| :year | 建立的年份(4 位数) |</span><br><span class="line">| :month | 建立的月份(2 位数) |</span><br><span class="line">| :i_month | 建立的月份(去掉开头的零)|</span><br><span class="line">| :day | 建立的日期(2 位数) |</span><br><span class="line">| :i_day| 建立的日期(去掉开头的零) |</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">#### 推送到服务器上</span><br></pre></td></tr></table></figure>

hexo n #写文章
hexo g #生成
hexo d #部署 #可与hexo g合并为 hexo d -g

1
2
3


#### 安装RSS插件

npm install hexo-generator-feed –save

1
2
3
开启RSS功能

编辑hexo/_config.yml,添加如下代码:

rss: /atom.xml #rss地址 默认即可
`