一、部落格搭建
1.1.1 安裝nodejs
官網: https://nodejs.org/en/ 下載下傳好後, 打開一直下一步即可.
檢視是否安裝成功
$ node -v
v12.10.0
1.1.2 安裝Git
Windows: 下載下傳并安裝 https://git-scm.com/download/win
1.1.2.1 git設定
配置推送的使用者名和郵箱
$ git config --global user.name “github’s Name”
$ git config --global user.email “[email protected]”
$ git config --list
生成ssh密鑰檔案:
$ ssh-keygen -t rsa -C "github的注冊郵箱"
找到C槽下
User→使用者名→.ssh→id_rsa.pub
複制裡面的内容到github的使用者頭像中
setting
的
SSH and GPG keys
→
New SSH key
裡面

1.2 更換下載下傳源
通過npm來下載下傳cnpm, 來提高Hexo的下載下傳速度
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
換好下載下傳源後,
1.3 安裝Hexo
$ cnpm install -g hexo-cli
1.4 搭建部落格
首先找個路徑, 建立檔案夾來存放Hexo建立的檔案
$ mkdir blog
初始化Hexo
$ hexo init
二、github設定
2.1 建立一個倉庫
倉庫的名字和賬号名稱一緻
設定主題
找到setting後, 向下拉, 找到Github Pages, 選擇主題, 然後确定
1.5 向github推送部落格
- 安裝 hexo-deployer-git
$ npm install hexo-deployer-git --save
- 編輯 _config.yml檔案
deploy:
type: git
repository: github上倉庫的ssh的位址
branch: master
-
本地部署部落格
網址輸入: hexo s
即可localhost:4000
- 遠端推送網站
- 如出現緩存引起的異常, 可以在生成指令前執行清除緩存指令:
hexo clean
- 生成靜态檔案:
heox generate
- 推送到網站:
或者 hexo deploy
dexo d