Github pages和Hexo搭建自己的博客
title: Hello Hexo
date: 2018-08-30 21:14:27
tags: hexo
photo: https://avatars1.githubusercontent.com/u/31088082?s=400&u=7a99ff83916afb3f4c5312bd78a1be17fe0e34ed&v=4
---
電腦環境是Windows,安裝好git後,所有搭建操作均在git bash內完成
1.需要安裝git, node.js, npm
註:第一次安裝Git會讓配置user信息
$git config --global user.name "yourname" #(yourname是git的用戶名) $git config --global user.email "youremail")
2.使用npm安裝hexo: npm install -g hexo
3.創建hexo文件夾,並單擊鼠標右鍵選擇 Git bash:(我的創建路徑是:E:\hexo)
4.在剛剛打開的git bash命令框中操作:
$hexo init #hexo 會自動創建網站所需要的文件
$npm install #安裝依賴包
$hexo generate # 等價於hexo g
$hexo server #現在可以用127.0.0.1:4000訪問hexo默認的hello world界面,等價於hexo s
5.部署到github (https://github.com/),
- 首先註冊登錄,然後創建頁面倉庫,Repository name 命名必須是 youname.github.io ,(youname 就是你註冊時候用的name)
ssh-keygen -t rsa -C "email" #生成ssh密鑰
,按三次回車鍵,密碼為空,這邊會生成id_rsa和_rsa.pub文件,打開id_rsa.pub,復制全文添加到GitHub 的Add SSH key中。- 最後可以驗證一下
ssh -T [email protected]
,看出現的是不是Hi "Yourname"
如果出現了你的github用戶名,則成功了
6.下載Hexo主題
$git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia #下載hexo的yilia 模板到自己的文件目錄下
打開項目目錄下的**_config.yml**文件,更改theme:yilia
▲註意: **_config.yml**文件中配置時:後面都要加空格,與:隔開
7.開啟評論功能:使用gitment
$npm install gitment --save #安裝gitment
然後在 https://github.com/settings/applications/new 進行註冊,獲取Client ID和Client Secret
打開themes/yilia目錄下的_config.yml文件進行修改並保存:
再次生成網站,提交網站:hexo d -g
就可以輸入網址:https://yourname.github.io打開你的博客了
Github pages和Hexo搭建自己的博客