Hexo之傻瓜攻略

Hexo搭建我的技術博客的網站,從零開始流程

搭建篇

  1. 必備Node.js環境
  2. 安裝配置hexo:
    • npm install -g hexo 安裝cli
    • hexo init 初始化hexo
    • npm install 安裝依賴
    • 輸入命令:git clone https://github.com/iissnan/hexo-theme-next themes/next (next爲主題名字),來得到更多主題
    • 更改_config.yml文件更換主題,另外注意如下配置項git

      theme: next
        deploy:
        type: git
        repo: https://github.com/Github暱稱/Github暱稱.github.io.git
        branch: master
  3. 設置文章title,在md文件中以下寫github

    ---
    title: 個人博客
    ---
  4. hexo deploy -g 或者 hexo g 生成博客頁面
  5. hexo server -g 或者 hexo s 本地服務器查看npm

    http://localhost:4000/瀏覽器

github部署篇

  1. 註冊Github帳號,並建立倉庫,名字爲 Github暱稱.github.io
  2. 安裝hexo-deployer-git自動部署發佈工具 npm install hexo-deployer-git --save
  3. hexo g (生成),hexo d (部署),可合併爲 hexo d -g
  4. 在瀏覽器訪問:https://Github暱稱.github.io/

異地速寫博客篇

先吐槽一下這個title,意思就是我換電腦了,從公司換到家裏或者哪天出去旅遊在網吧。。。忽然想寫博客了有木有,怎麼辦,好着急。。。服務器

解決方案: 使用github分支。一個分支用來存放Hexo生成的網站原始的文件,另外一個分支用來存放生成的靜態網頁。hexo

  • 直接刪除主題文件下的.git文件
  • 本地博客根文件夾路徑下執行如下命令:工具

    git init
     git checkout -b hexo
     git remote add origin https://github.com/Github暱稱/Github暱稱.github.io.git
     git add .
     git commit -m "提交說明"
     git push origin hexo
  • 執行到這裏,已經把本地的源文件(包括文檔文件)添加到了分支hexo上,master爲你的配置等文件。
  • 另一臺電腦上執行 git clone -b hexo https://github.com/Github暱稱/Github暱稱.github.io.git,而後再博客項目執行 npm install便可安裝好博客環境
  • 添加新的 .md文件放到 Hexo\source\_posts\ 路徑下
  • 生成新的博客並部署:post

    hexo g (生成),hexo d (部署),可合併爲 hexo d -g測試

  • 上面一步只是生成博客頁面而且發佈了,不要忘記把你寫的 XX.md 文件 add 上傳到你的github倉庫hexo分支中進行備份!網站

hexo d (部署) 到github上報錯 fatal: HttpRequestException encountered解決方法:

測試連接:https://bugsmaster.github.io/

相關文章
相關標籤/搜索