如果你能see到這個教程,說明你已經(jīng)了解了一些hexo的資料……不了解也沒啥,這是個教程,你可以照著來一遍,just this……
一、Node.js 安裝
通過brew安裝
安裝命令
brew install node #最新版的node.js包中已經(jīng)集成了npm包管理工具
使用下面的命令驗證是否安裝成功
node -v
npm -v
二、Hexo安裝與設(shè)置
命令
npm install hexo -g #表示全局安裝,npm默認為當前項目安裝
Hexo使用命令
hexo init <folder> #執(zhí)行init命令初始化hexo到你指定的目錄
hexo generate #自動根據(jù)當前目錄下文件,生成靜態(tài)網(wǎng)頁
hexo server #運行本地服務(wù)
三、配置github
如果你有g(shù)ithub帳號 ? 登錄 : 注冊再登錄;
創(chuàng)建一個新的倉庫,點擊New repository
,在Repository name
里填入username.github.io
,這里的username
必須和Owner
一樣,比如我填的是jiutianhuanpei.github.io
。
然后點擊Create repository
確認創(chuàng)建。
四、編寫、發(fā)布文章
1、創(chuàng)建博客
命令
hexo init username.github.io
2、更改配置
主題安裝
博客的樣式是可以隨我心意更改的,命令
cd username.github.io
git clone https://github.com/iissnan/hexo-theme-next themes/next
這個是極簡的主題,上面喵神的主題在這里,當然資源永遠是有更多的。
基礎(chǔ)配置
打開配置文件username.github.io/_config.yml
,修改幾個值,下面這幾個是必須改的,記得保存,鍵值之間有空格。
title: xxx的博客 //你博客的名字
author: xxx //你的名字
language: zh-Hans //語言 中文
theme: next //剛剛安裝的主題名稱
deploy:
type: git //使用Git 發(fā)布
repo: https://github.com/username/username.github.io.git // 剛創(chuàng)建的Github倉庫
主題配置
主題配置文件位置username.github.io/themes/next/_config.yml
,自行修改。
3、寫文章
在位置username.github.io/source/_posts
下創(chuàng)建.md
文件,用Markdown發(fā)揮吧。推薦軟件 Mou。文章例子
---
title: First Blood
---
>童話
我有一頭小毛驢,可是我從來都不騎
4、測試
命令
hexo s
服務(wù)啟動后,在瀏覽器中輸入https://localhost:4000即可訪問。
5、安裝hexo-deployer-git自動部署發(fā)布工具
命令
npm install hexo-deployer-git --save
6、發(fā)布
測試過后,我們就可以把生成的靜態(tài)網(wǎng)頁發(fā)布到我們的Github Pages中。
命令
hexo clean && hexo g && hexo d
如果是第一次,終端會讓你輸入github的帳號和密碼。
以后再執(zhí)行一下這個命令就可以直接發(fā)布了。
教程 over