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