【詳細】 →→→ →→→5分鐘 搭建免費個人博客
一、安裝
1.Git
- 安裝git
- 注冊github
- 創建倉庫username.github.io
2.Nodejs
- 安裝nodejs,包含npm
3.使用npm安裝Hexo
- 右鍵Git Bush ,輸入以下命令
npm install hexo -g6
二、編寫博客
1.本地創建博客文件夾
hexo init username.github.io
創建出一個名為“username.github.io”的文件夾。
2.更改配置
- 下載主題。官方主題
$ cd username.github.io
$ git clone https://github.com/iissnan/hexo-theme-next themes/next
- 在username.github.io/_config.yml中修改鍵值對
【鍵值之間必須有空格】
title: title //你博客的名字
author: name //你的名字
language: zh-Hans //語言 中文
theme: next //剛剛安裝的主題名稱
deploy:
type: git //使用Git 發布
repo: https://github.com/username/username.github.io.git // 剛創建的Github倉庫
3.寫文章
在username.github.io/source/_posts下創建后綴為.md文件,用Markdown語法編寫。
4.測試
hexo s
啟動測試服務器,在瀏覽器中輸入https://localhost:4000可訪問本地博客
→→→ →→→ 端口沖突解決
三、發布
1.安裝hexo-deployer-git自動部署發布工具【遠程博客】
npm install hexo-deployer-git -save
→→→ →→→ 使用Hexo搭建博客
否則下一步使用hexo d 命令時會出現以下錯誤:
2.發布
測試沒問題就生成靜態網頁文件發布至Github pages 中。
hexo clean
hexo g
hexo d
3.訪問
在瀏覽器中輸入 http://username.github.io就能夠訪問了。