Github Page + Hexo 搭建靜態博客傻瓜式教程

本文面向對象

  • 前端小白前端

  • windows用戶git

  • 懶癌晚期患者github

準備工做:

  1. 一個Github帳戶npm

  2. 安裝Gitwindows

  3. 安裝Node.jsbash

Step by Step


Step 1, 建立一個Github page

新建github page

  1. Repo name 的填寫格式爲 Github名 + github.io。舉個栗子,個人repo name爲 cnscorpions.github.io服務器

  2. Description能夠寫static blog/blog,反正你隨意就好網絡

  3. 點擊建立repohexo

Step 2, Hexo安裝以配置 (假設你已經安裝好Git和Node.js)

  • 打開Git bash命令行ssh

  • 安裝NPM ---> Taobao NPM 鏡像 (由於網絡環境很差,你懂的)
    $ npm install -g cnpm --registry=https://registry.npm.taobao.org

  • 安裝Hexo
    $ cnpm install -g hexo-cli

  • 建立blog根目錄
    $ hexo init blog

  • 生成靜態文件
    $ hexo g

  • 安裝Hexo-server模塊
    $ cnpm install hexo-server --save

  • 運行本地服務器 (必定要在blog根目錄下運行)
    $ hexo s

  • 打開http://localhost:4000/已經能夠看到一篇內置的blog了

Step 3, 安裝Hexo主題 (Git在線安裝 VS 本地安裝)

  • Git安裝

$ hexo clean
$ git clone https://github.com/iissnan/hexo-theme-next
  • 修改配置文件
    _config.yml/theme ---> next

  • 更新主題

$ hexo c 
$ hexo g   
$ hexo s

Step 4, 安裝SSH

  • 安裝hexo-deployer-git模塊
    $ cnpm install hexo-deployer-git --save

  • 修改配置文件

deploy:
  type: git
  repo: https://github.com/cnscorpions/cnscorpions.github.io.git
  branch: master
  • 檢查電腦中是否存在SSH key
    $ ls -al ~/.ssh

  • 建立新的SSH key

$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter] ---> 不要移動文件位置
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
  • 複製id_rsa.pug

  • 複製到Github SSH key

  • 搞定
    $ hexo g ---> $ hexo d ----> OVER

PS: 暫時先這樣了,歡迎拍磚!

相關文章
相關標籤/搜索