hexo
npm install hexo-cli -g // 官方帶命令行安裝
npm install hexo -g // 安裝
npm update hexo -g //升級(jí)
hexo init //初始化
間寫
hexo n "我的博客" == hexo new "我的博客" // 新建文章
hexo p == hexo publish
hexo g == hexo generate //生成
hexo s == hexo serdev //啟動(dòng)服務(wù)預(yù)覽
hexo d == hexo deploy //部署
服務(wù)器
hexo server Hexo //會(huì)監(jiān)視文件變動(dòng)并自動(dòng)更新,您無須重啟服務(wù)器。
hexo server -s //靜態(tài)模式
hexo server -p 5000 //更改端口
hexo server -i 192.168.1.1 //自定義 IP
hexo clean //清除緩存 網(wǎng)頁正常情況下可以忽略此條命令
hexo g //生成靜態(tài)網(wǎng)頁
hexo d //開始部署
監(jiān)視文件變動(dòng)
hexo generate //使用 Hexo 生成靜態(tài)文件快速而且簡(jiǎn)單
hexo generate --watch //監(jiān)視文件變動(dòng)
完成后部署
兩個(gè)命令的作用是相同的
hexo generate --deploy
hexo deploy --generate
hexo deploy -g
hexo server -g
草稿
hexo publish [layout] <title>
模版
hexo new "postName" //新建文章
hexo new page "pageName" //新建頁面
hexo generate //生成靜態(tài)頁面至public目錄
hexo server //開啟預(yù)覽訪問端口(默認(rèn)端口4000,'ctrl + c'關(guān)閉server)
hexo deploy //將.deploy目錄部署到GitHub
hexo new [layout] <title>
hexo new photo "My Gallery"
hexo new "Hello World" --lang tw
變量 | 描述
---|---
layout | 布局
title | 標(biāo)題
date | 文件建立時(shí)間
title: 使用Hexo搭建個(gè)人博客
layout: post
date: 2014-03-03 19:07:43
comments: true
categories: Blog
tags: [Hexo]
keywords: Hexo, Blog
description: 生命在于折騰,又把博客折騰到Hexo了。給Hexo點(diǎn)贊。
>#### 模版(Scaffold)
```python
hexo new photo "My Gallery"
變量 | 描述 |
---|---|
layout | 布局 |
title | 標(biāo)題 |
date | 文件建立時(shí)間 |
設(shè)置文章摘要
以上是文章摘要 <!--more--> 以下是余下全文
寫作
hexo new page <title>
hexo new post <title>
變量 | 描述 |
---|---|
:title | 標(biāo)題 |
:year | 建立的年份(4 位數(shù)) |
:month | 建立的月份(2 位數(shù)) |
:i_month | 建立的月份(去掉開頭的零) |
:day | 建立的日期(2 位數(shù)) |
:i_day | 建立的日期(去掉開頭的零) |
推送到服務(wù)器
hexo n //寫文章
hexo g //生成
hexo d //部署 //可與hexo g合并為 hexo d -g
報(bào)錯(cuò)
1.找不到git部署
ERROR Deployer not found: git
解決方法
npm install hexo-deployer-git --save
- 部署類型設(shè)置git
hexo 3.0 部署類型不再是github,_config.yml 中修改
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type: git
repository: git@***.github.com:***/***.github.io.git
branch: master
- xcodebuild
xcode-select: error: tool 'xcodebuild'
requires Xcode, but active developer directory '
/Library/Developer/CommandLineTools'
is a command line tools instance
解決方法
npm install bcrypt
4.RSS不顯示
安裝RSS插件
npm install hexo-generator-feed --save
開啟RSS功能
編輯hexo/_config.yml,添加以下代碼:
rss: /atom.xml //rss地址 默認(rèn)即可
開啟評(píng)論
1.我使用多說代替自帶的評(píng)論,在多說 網(wǎng)站注冊(cè) > 后臺(tái)管理 > 添加新站點(diǎn) > 工具 === 復(fù)制通用代碼 里面有 short_name
在根目錄 _config.yml 添加一行 disqus_shortname: jslite 是在多說注冊(cè)時(shí)產(chǎn)生的
復(fù)制到 themes\landscape\layout_partial\article.ejs
把
<% if (!index && post.comments && config.disqus_shortname){ %>
<section id="comments">
<div id="disqus_thread">
<noscript>Please enable JavaScript to view the <a >comments powered by Disqus.</a></noscript>
</div>
</section>
<% } %>
改為
<% if (!index && post.comments && config.disqus_shortname){ %>
<section id="comments">
<!-- 多說評(píng)論框 start -->
<div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>
<!-- 多說評(píng)論框 end -->
<!-- 多說公共JS代碼 start (一個(gè)網(wǎng)頁只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:'<%= config.disqus_shortname %>'};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- 多說公共JS代碼 end -->
</section>
<% } %>
編輯:yanjan