Mac OS 搭建 Github Pages 個(gè)人博客

環(huán)境 mac os , 文件路徑:桌面 Hexo文件夾

配置本地 hexo

  • 1 安裝 Node.js

  • 2 git

  • 3 安裝Hexo

    sudo npm install -g hexo
    
  • 4 創(chuàng)建blog文件

    hexo init blog
    
  • 5 安裝 (cd 到 blog目錄下)

    npm install
    
  • 6 啟動(dòng)hexo 服務(wù)器

    hexo s
    
  • 7 替換 next 主題 (在 blog下)

    git clone https://github.com/iissnan/hexo-theme-next themes/next
    修改 _config.yml 文件
    theme: landscape 改成 theme: next

  • 8 啟動(dòng)hexo 服務(wù)器

    hexo clean
    hexo g
    hexo s
    
  • 9 開啟MathJax

修改 themes\themes\next_config.yml
mathjax:
enable: true

  • 10 markdown 與 mathjax兼容問題

當(dāng)使用Latex處理數(shù)學(xué)公式的時(shí)候 會(huì)出現(xiàn)兼容問題例如 :$h_\theta (x)$ 單個(gè) $$直接基本正常,多個(gè)的時(shí)候可能就出現(xiàn)異常 主要原因是 _ 沖突, 在 _前面加上 \ 即可。

Github Pages 配置

  • 在github上創(chuàng)建repository

1.png

2.png

創(chuàng)建成功后 可以使用 http://用戶名.github.io 來(lái)訪問。

提交內(nèi)容到Github Pages

  • 1 Clone repository

    git clone https://github.com/username/username.github.io
    
  • 2 生成對(duì)應(yīng)文件

    cd username.github.io
    echo "Hello World" > index.html
    
  • 3 推送本地文件到Github pages

    git add --all
    git commit -m "Initial commit"
    git push -u origin master
    

同步本地的 hexo 博客 到 github 上

  • 1 安裝一個(gè)擴(kuò)展( Hexo/blog 下)

    sudo npm install hexo-deployer-git --save
  • 2 配置_config.yml

    deploy:
    type: git
    repository: https://github.com/username/username.github.io.git
    branch: master
  • 3 清除緩存上傳本地hexo 本地博客到Github pages

    hexo clean 
    hexo g
    hexo d
    

關(guān)于配置Hexo可能出現(xiàn)的一些錯(cuò)誤

  • 1 權(quán)限問題

    sudo chown -R 路徑/Hexo/blog
    
  • 2 無(wú)法更新到Github pages

    很多情況是配置自己的git路徑出問題,還有另一種情況是有些時(shí)候直接 hexo d 會(huì)直接報(bào)錯(cuò)誤。
    如果遇到類似情況, 可以嘗試使用 "提交內(nèi)容到Github Pages" 步驟先提交一個(gè) hello word 試試。然后在hexo d 同步整個(gè)blog

參考資料

https://pages.github.com/
http://jeasonstudio.github.io/2016/05/26/Mac%E4%B8%8A%E6%90%AD%E5%BB%BA%E5%9F%BA%E4%BA%8EGitHub-Page%E7%9A%84Hexo%E5%8D%9A%E5%AE%A2/

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容