使用Hexo建立獨立博客

jopen 8年前發布 | 33K 次閱讀 Hexo 建站系統CMS

Hexo介紹

Hexo是一個快速、簡潔且高效的博客框架。

Hexo使用 Markdown 來編寫文章,通過Hexo生成靜態網頁,然后部署到服務器上。

安裝 NodeJS

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
nvm install 4

或者到Nodejs官網直接下載安裝

https://nodejs.org/en/

安裝 Hexo

npm install hexo-cli -g

初始化工作

hexo init blog
cd blog
npm install
hexo server

部署到Gitcafe

創建賬號

https://gitcafe.com/

創建項目

建一個跟用戶名相同的項目

https://gitcafe.com/GitCafe/Help/wiki/Pages-%E7%9B%B8%E5%85%B3%E5%B8%AE%E5%8A%A9

添加ssh key

使用ssh-keygen 生成 ssh key

ssh-keygen -t rsa -C "your name"

這樣默認會在本地的~/.ssh目錄下生成id_rsa,id_rsa.pub兩個文件,id_rsa是私鑰,id_rsa.pub是公鑰。

cat ~/.ssh/id_rsa.pub

把里面的內容拷貝到gitcafe的ssh keys設置中

安裝部署插件

npm install hexo-deployer-git --save

配置hexo

打開_config.yml, 修改deploy模塊

deploy:
- type: git
  repo: git@gitcafe.com:xxxx/xxxx.git
  branch: gitcafe-pages

開始部署

hexo deploy

部署成功后,通過 http://xxxx.gitcafe.io 訪問你的網站

xxxx 是你gitcafe的用戶名

寫作命令

  • 建立新文章:hexo n “新文章名”
  • 預覽文章:hexo s
  • 生成網頁:hexo g
  • 發布文章:hexo d
  • 生成網頁并發布文章:hexo d -g

來自: https://aswifter.com/2016/01/16/hexo-with-gitcafe/

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!