首先要有Git和npm環(huán)境.
安裝hexo:
npm install hexo -g
.初始化hexo:
hexo init blog
, 將建立"blog"為名的目錄并在此初始化, Hexo 即會自動在目標文件夾建立網(wǎng)站所需要的所有文件.安裝依賴包:
cd dir && npm install
.本地啟動測試:
hexo server
, 可以訪問127.0.0.1:4000查看.
以上參考HEXO.Github上新建一個repository, 名字為
yoursite.github.io
.修改本地的
_config.yml
文件, 找到#site
一欄, 修改博客的title, 然后在最后的deploy:
處增加:
type: github
repository: https://github.com/Your_Github_Account/yoursite.github.io.git
branch: master
- 修改完后, 把本地博客文件部署到github上去:
hexo generate # 生成靜態(tài)頁面至public目錄
hexo deploy # 將.deploy目錄部署到GitHub
在github部署完成后, 訪問
yoursite.github.io
就能看到自己搭建的博客了.添加/修改文章
hexo n 文章名 #在source\_posts\目錄下新建文章
hexo g # 生成靜態(tài)文件, 每新建文章都需要執(zhí)行
hexo d # 部署到git
- 添加評論系統(tǒng):
國外比較常用的評論系統(tǒng)有disqus等, 這個在hexo中也是默認開啟的, 如果我們要添加其他的評論系統(tǒng), 在國內推薦使用:搜狐暢言-專業(yè)的社會化評論系統(tǒng).
首先需要在配置文件中禁用disqus, 編輯根目錄的_config.yml文件:
查找并注釋掉disqus_shortname
一行.
然后, 編輯themes\landscape\layout_partial\comment.ejs并添加:
<% if ( page.comments){ %>
<section id="comment">
暢言js代碼
</section>
<% } %>
參考:
http://www.reibang.com/p/05289a4bc8b2
http://segmentfault.com/blog/zhongbaitu/1190000000458953