參考知乎文章,參考文章更加詳細,但是和參考文章有出入的地方請以我的文章為主
https://zhuanlan.zhihu.com/p/35668237
安裝 Node.js
sudo apt install nodejs一開始就遇到了版本問題,Ubuntu 上的版本太老了,應該把 nodejs 升級到最新版本
https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stableTo upgrade to latest version (and not current stable) version, you can use
sudo n latest- Fix PATH:
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node- To undo:
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g nYou may need to restart your terminal to see the updated node version.
下面的一部分步驟可以參考原文章,不再贅述
安裝 Hexo
按照官網的方法
npm install hexo-cli -g
hexo init blog
cd blog
npm install
hexo server如果有步驟錯誤也許可以嘗試一下加 sudo?
連接 Github 和本地
npm install hexo-deployer-git --savegit config --global user.name "SherlockShemol"
git config --global user.email "shemol@163.com"生成密鑰 SSH key
ssh-keygen -t rsa -C "shemol@163.com"cat ~/.ssh/id_rsa.pub將輸出的內容複製到框中,在 SSH keys 中貼上,點擊確定儲存。
輸入 ssh -T git@github.com,如果出現你的使用者名稱,那就成功了。
打開部落格根目錄下的 _config.yml 檔案,這是部落格的配置檔,在這裡你可以修改與部落格相關的各種資訊。
修改最後一行的配置:
deploy:
type: git
repository: <https://github.com/SherlockShemol/SherlockShemol.github.io>
branch: masterrepository 修改為你自己的 github 專案地址。
修改主題
看原部落格
Even 主題下 npm install 報錯
https://sobaigu.com/hexo-renderer-sass-error.html
採用
npm uninstall hexo-renderer-sass
npm i --save hexo-renderer-sass-next剩下的看文件就可以了
Hexo 部署問題
github 新規規定再從 hexo 提交程式碼只能用 token。
解決方法:
- 去
Settings->Developer settings->Personal access tokens->Personal access tokens生成一個新的令牌 hexo -d執行完後會有一個對話框提示你輸入帳號密碼。注意,這裡要輸入的不是你的密碼而是 token
參考:https://blog.csdn.net/qq_21040559/article/details/122621179