window本地使用Hexo搭建個人博客

轉載請表明出處 https://blog.csdn.net/Amor_Leo/article/details/85396596 謝謝

安裝git

  • 官網 一路next.(可以自定義安裝目錄)

安裝node.js

  • 官網 一路next.(可以自定義安裝目錄)

安裝hexo

  • 安裝hexo
    打開git bash或者(cmd)
npm install -g hexo-cli
  • 初始化Hexo
    打開git bash或者(cmd)
hexo init <folder>
cd <folder>
npm install
├── node_modules #npm依賴包
├── scaffolds #文章等模板
├── source  #博客正文和其他源文件
├── themes   #主題
├── _config.yml   #配置文件
├── db.json   #source解析得到的
├── package.json  #定義了hexo所需要的各種模塊
└── package-lock.json
  • 啓動服務器
    打開Git Bash
hexo server

打開 http://localhost:4000
在這裏插入圖片描述

hexo發佈至github(coding雙部署)

創建github賬號

創建倉庫

倉庫名爲:<Github賬號名稱>.github.io
勾選 Initialize this repository with a README
在這裏插入圖片描述

添加SSH祕鑰

  • 設置Git的user name和email:
git config --global user.name "your name"
git config --global user.email "your email"
  • 打開Git Bash,輸入以下命令,回車三次
ssh-keygen -t rsa -C "your email"

打開github,登錄,添加的是“id_rsa.pub”(C:\Users\Administrator.ssh\id_rsa.pub)裏面的公鑰.
在這裏插入圖片描述
在這裏插入圖片描述

  • 測試SSH是否成功
ssh -T [email protected]
yes

如果提示:Hi XXX ,You’ve successfully authenticated, but GitHub does not provide shell access. 說明你連接成功了

  • 修改_config.yml(配置文件)
deploy:
  type: git
  repo: [email protected]:你的github賬號名稱/你的github賬號名稱.github.io.git
  branch: master
  • 如果你有Coding賬號
    添加ssh
    創建倉庫 倉庫名稱是你coding賬號名稱
    點擊Page服務,勾選 一鍵開啓靜態 Pages
deploy:
- type: git
  repo: [email protected]:你的github賬號名稱/你的github賬號名稱.github.io.git
  branch: master
- type: git
  repo: [email protected]:你的coding賬號名稱/你的coding賬號名稱.git
  branch: master
  • 安裝部署插件
npm install hexo-deployer-git --save
  • 部署
hexo clean  
hexo g 
hexo d

hexo clean : 清除緩存
hexo g : 重新生成代碼
hexo d : 部署

  • 訪問
    https://<Github賬號名稱>.github.io
    https://<Coding賬號名稱>.coding.me

主題優化

cd <folder>
git clone https://github.com/iissnan/hexo-theme-next themes/next
  • 修改_config.yml
theme: next
  • NexT個性化設置
    NexT官網

    • 修改\themes\next_config.yml
    #scheme: Muse
    scheme: Mist
    #scheme: Pisces
    #scheme: Gemini
    
  • 部署

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