安裝nodejs環境
查看node版本
node -v
安裝cnpm
npm install cnpm -g --registry=https://registry.npm.taobao.org
安裝 Hexo
cnpm install -g hexo-cli
查看版本
hexo -v
創建本地博客
cd d:/hexo/blog
hexo init
cd d:/hexo/blog
cnpm install
hexo s或hexo server
在博客上寫新文章
另外打開一個cmd窗口
cd d:/hexo/blog
hexo new "My First Post"
/source/_posts 路徑下,會有一個 My-First-Post.md 的文件
對他進行編輯(寫博客)
創建靜態文件
hexo g或hexo generate
瀏覽器輸入localhost:4000 新文章已出現
部署到GitHub或Gitee
打開_config.yml文件
# Site
title: 博客名
subtitle: ''
description: ''
keywords:
author: 你的姓名
language: zh-Hans
timezone: ''
# URL
url: http://yoursite.com
root: /yyy
注:yyy是你的倉庫名
找到 # Deployment
github
deploy:
type: git
repository: https://github.com/XXX/XXX.github.io.git
branch: master
gitee
deploy:
type: git
repository: https://gitee.com/XXX/yyy.git
branch: master
安裝自動部署發布工具
cnpm install hexo-deployer-git --save
發布
hexo clean && hexo g && hexo d
首次發布需要在shell中輸入賬號和密碼。
注:發布時GiteePages服務必須是非啟動狀態,否則找不到倉庫
發布完后以Gitee為例,進入gitee blog倉庫的頁面->服務->Gitee Pages->啟動
給文章添加type,categories,站內搜索,流量分析等功能(略),自行度娘