搭建一個hexo博客

安裝依賴環境

  • git
  • npm
  • nodejs

安裝git

sudo apt install git

安裝npm

sudo apt install npm

安裝nodejs

sudo apt install nodejs

安裝Hexo

npm install -g hexo-cli

hexo的使用

hexo init folder

初始化一個文件夾作爲你的blog

hexo new file

在/folder/source/_posts/路徑下新建一個file.md文件

hexo s

打開本地預覽,在http://localhost:4000預覽博客

修改Hexo主題

你可以在Themes|Hexo下載你喜歡的主題,將下載好的主題文件夾移動到/folder/themes/

git clone theme's site

你可以添加about,tags,categories,contact等信息:

hexo new page about
hexo new page tags
hexo new page categories
hexo new page contact

修改/folder/_config.yml完成主題的更換

theme: your theme

/folder/themes/your theme可以選擇配置你的主題樣式,如果你會CSS,你也可以修改主題的樣式模板

部署到github遠端

添加你的github信息

git config --global user.name "yourname"
git config --global user.email "youremail"

創建ssh

ssh-keygen -t rsa -C "youremail"

~/.ssh/文件夾中存在id_rsaid_rsa.pub兩個文件,其中id_rsa.pub是公鑰,把它複製粘貼到github上:

  • setting > SSH and GPG keys > New SSH key — 粘貼

安裝deploy-git

npm install hexo-deployer-git --save

修改/folder/_config.yml文件:

deploy:
  type: 'git'
  repo: https://github.com/yourGithub/yourGithub.github.io.git
  branch: master

推送到遠端

hexo d
  • 通過hexo clean可以清除之前生成的內容
  • 通過hexo g生成靜態博客

更多教程請參考Documentation|Hexo


附上我的hexo博客

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