1.需要安裝的應(yīng)用程序
-
node.js 地址
-
集成git,安裝xcode即可
-
安裝hexo
終端輸入 $ sudo npm install -g hexo-cli
(sudo 執(zhí)行管理員權(quán)限)
2.使用Hexo來(lái)顯示博客
創(chuàng)建一個(gè)文件夾(blogxxx)(所有命令都是在該文件中)
- 進(jìn)入到根目錄執(zhí)行命令
- cd blogxxx
- hexo init
- npm install
- hexo s (運(yùn)行hexo,以后要在本地運(yùn)行博客只要輸入該命令即可)
- http://localhost:4000/ 復(fù)制網(wǎng)址即可預(yù)覽
- Ctrl+C(停止運(yùn)行)
配置_config.yml文件
(1).顯示圖片的方法多糠,使用asset-image:
- cd到文件目錄下孤澎,執(zhí)行 npm install https://github.com/CodeFalling/hexo-asset-image --save
- 修改_config.yml 中有 post_asset_folder:
true
- 在source/_posts中創(chuàng)建一個(gè)xxx.md文件同名的文件夾xxx,該xxx文件夾放入xxx.md文件中使用到的圖片,在xxx.md中引用圖片方式為:

(2).主題
- git clone https://github.com/wuchong/jacman.git themes/jacman
- jacman文件夾下,從終端進(jìn)入刪除掉相關(guān)的.git和.gitignore文件
- 在_config.yml文件中搜索theme赁严,將theme:xxx設(shè)置為 theme: jacman(主題名)
3.關(guān)聯(lián)github倉(cāng)庫(kù)的鏈接
- 在_config.yml文件中 ,將deploy改為
- type: git
- repository: 倉(cāng)庫(kù)鏈接
- branch: master(分支)
關(guān)鍵步驟:關(guān)聯(lián)命令
- npm install hexo-deployer-git --save
設(shè)置url
- 在
_config.yml
文件中的http://yoursite.com
替換為http://倉(cāng)庫(kù)名.github.io
hexo 相關(guān)命令
設(shè)置git身份信息
-
git config --global user.name "你的用戶名"
-
git config --global user.email "你的郵箱"
-
hexo clean 清理
-
hexo g 生成靜態(tài)站點(diǎn)(位于public目錄)
-
hexo deploy 發(fā)布
-
hexo deploy --generate 生成靜態(tài)站點(diǎn)并發(fā)布
hexo的哪些文件需要上傳到github上
hexo/
- 不需要上傳
- public/ 生成的靜態(tài)頁(yè)面,由hexo deploy自動(dòng)上傳到gh-page分支
- node_modules/ hexo需要的模塊榜轿,不需要上傳GitHub
- package.json 記錄hexo需要的包信息,不需要上傳GitHub
- .gitignore hexo生成默認(rèn)的.gitignore朵锣,它已經(jīng)配置好了不需要上傳的hexo文件
- 需要上傳
- themes/ 主題文件谬盐,需要上傳GitHub的dev分支
- source/ 博文md文件,需要上傳GitHub的dev分支
- _config.yml 全局配置文件诚些,需要上傳GitHub的dev分支