Github Pages和Hexo建立靜態博客網站

Github Pages和Hexo建立靜態博客網站

安裝Node.js

本人是window環境,因此下載window版。node

下載地址:https://nodejs.org/en/download/git

下載 msysgit

下載地址:https://git-for-windows.github.io/github

Hexo

點擊鼠標右鍵菜單Git Bash Herenpm

npm install hexo-cli -g
npm install hexo --save
#若是命令沒法運行,能夠嘗試更換taobao的npm源
npm install -g cnpm --registry=https://registry.npm.taobao.org

建立一個blog目錄windows

執行命令:瀏覽器

hexo init
npm install

安裝插件,可跳過此步驟:hexo

npm install hexo-generator-index --save
npm install hexo-generator-archive --save
npm install hexo-generator-category --save
npm install hexo-generator-tag --save
npm install hexo-server --save
npm install hexo-deployer-git --save
npm install hexo-deployer-heroku --save
npm install hexo-deployer-rsync --save
npm install hexo-deployer-openshift --save
npm install hexo-renderer-marked@0.2 --save
npm install hexo-renderer-stylus@0.2 --save
npm install hexo-generator-feed@1 --save
npm install hexo-generator-sitemap@1 --save

運行本地Hexo:網站

hexo generate
hexo server

瀏覽器查看效果:.net

localhost:4000

上傳到Github

找到主項目的https地址:https://xxx/github.io.git插件

打開blog文件夾下_config.yml文件修改:

deploy:
  type: git
  repository: https://xxx/github.io.git
  branch: master

執行命令:

hexo g -d

換主題

Hexo主題:https://hexo.io/themes/

執行命令下載主題:

git clone https://github.com/xxx.git(主題地址) themes/xxx(主題文件夾)

修改_config.yml文件:

theme: xxx(主題名)

執行命令:

hexo g
hexo s

打開http://localhost:4000/便可看到效果。

部署到Github

執行命令:

hexo clean   
hexo g -d

寫文章

hexo n "文章標題" #新建md文件
hexo g -d #生成並部署

參考:

相關文章
相關標籤/搜索