1.安裝GIT簇宽、node.js、cnpm
git
可以到git官網(wǎng)下載相應平臺的版本進行安裝惜互。直接在(github/git)下載吴菠。
node.js
到node.js官網(wǎng)下載相應平臺的最新版本
cnpm
因為要借助npm這個包管理器進行安裝,但npm比較慢清寇,因此用npm去安裝cnpm,打開cmd:
npm install -g cnpm --registry=http://registry.npm.taobao.org
2.安裝Hexo
打開cmd绘趋,執(zhí)行以下命令:
cnpm install -g hexo
安裝好了以后,用cmd跳到你想要放blog的目錄下颗管。
初始化:
hexo init
生成靜態(tài)頁面
hexo g
本地運行
hexo s
3.新建倉庫并推送
在GitHub上陷遮,新建repository
建立與你用戶名對應的倉庫,倉庫名必須為【 your_username.github.io】垦江,例如我的是YDP1994.github.io帽馋。
復制repo
例如我的是https://github.com/xiaobinhong1/YDP1994.github.io.git
配置博客
進入你的hexo文件夾根目錄下,用編輯器打開_config.yml比吭,修改deploy項绽族,如下(根據(jù)你的github進行相應更改):
ploy:
type: git
repo: https://github.com/xiaobinhong1/YDP1994.github.io.git
branch: master
注意:在分配符后面要加空格
推送到GitHub
hexo d
每次修改完本地的文件后要執(zhí)行以下命令,重新部署到github上:
hexo clean
hexo g
hexo d
常用命令
hexo new "postName"
#新建文章
hexo new page "pageName"
#新建頁面
hexo generate
#生成靜態(tài)頁面至public目錄
hexo server
#開啟預覽訪問端口(默認端口4000衩藤,'ctrl + c'關閉server)
hexo deploy
#將.deploy目錄部署到GitHub
hexo help
# 查看幫助
4.常見錯誤
ERROR Deployer not found: git
解決方法:打開命令行吧慢,輸入
npm install --save hexo-deployer-git
FATAL Something's wrong.
原因:需要為自己配置身份信息。
解決方法:打開命令行赏表,輸入
git config --global user.name "yourname"
git config --global user.email "youremail"
參考文章與視頻
http://www.reibang.com/p/8681ab76da08
https://www.bilibili.com/video/av44544186