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

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

安裝Node.js

本人是window環境,所以下載window版。

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

下載 msysgit

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

Hexo

點擊鼠標右鍵菜單Git Bash Here

npm install hexo-cli -g
npm install hexo --save
#如果命令無法運行,可以嘗試更換taobao的npm源
npm install -g cnpm --registry=https://registry.npm.taobao.org

創建一個blog目錄

執行命令:

hexo init
npm install

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

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 [email protected] --save
npm install [email protected] --save
npm install hexo-generator-feed@1 --save
npm install hexo-generator-sitemap@1 --save

運行本地Hexo:

hexo generate
hexo server

瀏覽器查看效果:

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 #生成並部署

參考:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章