hexo經常使用命令筆記

hexo 皮膚Github
hexo 皮膚預覽javascript

hexo

bashnpm install hexo -g #安裝  
npm update hexo -g #升級  
hexo init #初始化

簡寫

hexo n "個人博客" == hexo new "個人博客" #新建文章
hexo p == hexo publish
hexo g == hexo generate#生成
hexo s == hexo server #啓動服務預覽
hexo d == hexo deploy#部署html

服務器

hexo server #Hexo 會監視文件變更並自動更新,您無須重啓服務器。
hexo server -s #靜態模式
hexo server -p 5000 #更改端口
hexo server -i 192.168.1.1 #自定義 IPjava

hexo clean #清除緩存 網頁正常狀況下能夠忽略此條命令
hexo g #生成靜態網頁
hexo d #開始部署git

監視文件變更

hexo generate #使用 Hexo 生成靜態文件快速並且簡單
hexo generate --watch #監視文件變更github

完成後部署

兩個命令的做用是相同的
hexo generate --deploy
hexo deploy --generatenpm

hexo deploy -g
hexo server -gxcode

草稿

hexo publish [layout] <title>緩存

模版

hexo new "postName" #新建文章
hexo new page "pageName" #新建頁面
hexo generate #生成靜態頁面至public目錄
hexo server #開啓預覽訪問端口(默認端口4000,'ctrl + c'關閉server)
hexo deploy #將.deploy目錄部署到GitHubbash

hexo new [layout] <title>
hexo new photo "My Gallery"
hexo new "Hello World" --lang tw服務器

變量 描述
layout 佈局
title 標題
date 文件創建日期
title: 使用Hexo搭建我的博客
layout: post
date: 2014-03-03 19:07:43
comments: true
categories: Blog
tags: [Hexo]
keywords: Hexo, Blog
description: 生命在於折騰,又把博客折騰到Hexo了。給Hexo點贊。

模版(Scaffold)

hexo new photo "My Gallery"

變量 描述
layout 佈局
title 標題
date 文件創建日期

設置文章摘要

以上是文章摘要 <!--more--> 如下是餘下全文

寫做

hexo new page <title>
hexo new post <title>

變量 描述
:title 標題
:year 創建的年份(4 位數)
:month 創建的月份(2 位數)
:i_month 創建的月份(去掉開頭的零)
:day 創建的日期(2 位數)
:i_day 創建的日期(去掉開頭的零)

推送到服務器上

hexo n #寫文章
hexo g #生成
hexo d #部署 #可與hexo g合併爲 hexo d -g

報錯

1.找不到git部署

ERROR Deployer not found: git

解決方法

npm install hexo-deployer-git --save

3.部署類型設置git

hexo 3.0 部署類型再也不是github_config.yml 中修改

bash# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
  type: git
  repository: git@***.github.com:***/***.github.io.git
  branch: master

4. xcodebuild

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

npm install bcrypt

5. RSS不顯示

安裝RSS插件

npm install hexo-generator-feed --save

開啓RSS功能

編輯hexo/_config.yml,添加以下代碼:

rss: /atom.xml #rss地址  默認便可

開啓評論

1.我使用多說代替自帶的評論,在多說 網站註冊 > 後臺管理 > 添加新站點 > 工具 === 複製通用代碼 裏面有 short_name

  1. 在根目錄 _config.yml 添加一行 disqus_shortname: jslite 是在多說註冊時產生的

  2. 複製到 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 href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</section>
<% } %>

改成

html<% if (!index && post.comments && config.disqus_shortname){ %>
  <section id="comments">
    <!-- 多說評論框 start -->
    <div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>
    <!-- 多說評論框 end -->
    <!-- 多說公共JS代碼 start (一個網頁只需插入一次) -->
    <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>
<% } %>
相關文章
相關標籤/搜索