Window 下安裝 hexo ,創建自己的博客

首先得安裝 nodejs ,看我以前寫得文章:
Window下如何安裝 nodejs

當配置好路徑之後,使用如何命令:

npm install -g hexo-cli

輸入 hexo -v 看看是否成功:
在這裏插入圖片描述
爲了避免編碼問題,建議都採用 gitbash 命令行操作,反正我吃過虧了!!!!

接着,在你隨便哪個盤下,新建一個 文件夾,比如MyBlog,然後使用 hexo init MyBlog:
在這裏插入圖片描述
接着進入 MyBlog 文件夾,安裝 npm install,發現報錯

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

audited 6890 packages in 6.373s
found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

按照提示,npm audit fix ,還是會報錯,繼續按照提示使用 npm audit fix --force

接着使用 hexo g 生成生成靜態網頁,然後使用 hexo s 啓動服務,然如 localhost:4000
在這裏插入圖片描述

二、關聯github

使用命令:

npm install hexo-deployer-git --save

提示:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\hexo-deployer-git\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ [email protected]
added 18 packages from 18 contributors and audited 6968 packages in 6.638s
found 0 vulnerabilities

說的是蘋果的,window 不用管。

接着,去到github,創建一個以你名字命名的工程,記得後面加 github.io
在這裏插入圖片描述
如果 github 是 shh,還需要本地生成一下 ssh:

ssh-keygen -t rsa -C youremailaddr

然後把公鑰的內容複製到github即可:
在這裏插入圖片描述

重點來了,修改_config.yml ,強烈建立用vi編輯!!!

vi _config.yml,修改格式,yourname 爲你github的名字

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

接着輸入幾條命令:

  • hexo clean 清緩存
  • hexo g 生成靜態網頁
  • hexo deploy 發佈

然後輸入 你的github名字 + github.io 即可
在這裏插入圖片描述

關於網站的其他配置,我們後面再單獨講

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