1. 安装
1.1 初始化
1 | mkdir dohttp && cd dohttp |
- vi .gitignore
1 | .DS_Store |
1.2 主题
1 | git submodule add https://github.com/theme-next/hexo-theme-next themes/next |
1.3 开始
1 | hexo new post hello |
1.4 分类和标签
- 标签
1 | hexo new page tags |
- 分类
1 | hexo new page categories |
1.5 主页menu
1 | menu: |
2. 插件
2.1 持久链接
1 | npm install hexo-abbrlink --save |
config
1
2
3
4permalink: post/:abbrlink.html
abbrlink:
alg: crc16 #support crc16(default) and crc32
rep: hex #support dec(default) and hex
2.2 图片相对路径
1 | npm install hexo-asset-image --save |
config
1
post_asset_folder: true
2.3 本地搜索
1 | npm install hexo-generator-searchdb --save |
config
1
2local_search:
enable: true
2.4 自动分类
1 | npm install hexo-auto-category --save |
config
1
2
3auto_category:
enable: true
depth:
2.5 自定义主页
- npm remove hexo-generator-index
- Add
index.md
tosource
folder.
3. 部署
3.1 部署到github pages
部署到github
1
2
3
4
5
6deploy:
-
type: git
repo:
github: git@github.com:unix2dos/dohttp.git
branch: gh-pages安装并部署
1
2
3npm install hexo-deployer-git --save
hexo clean --config source/_data/next.yml && hexo g -d --config source/_data/next.yml
3.2 部署到腾讯云cloudbase
强烈建议选择上海地区
开通hexo应用
开通静态网站托管
命令
1
2tcb login
hexo g --config source/_data/next.yml && tcb hosting deploy ./public -e dohttp-8g3uegkw004f490e -r bj
3.3 cloudbase自动部署
Github action
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20on: [push] # push 代码时触发
jobs:
deploy:
runs-on: ubuntu-latest
name: Tencent Cloudbase Github Action Example
steps:
- name: Checkout
uses: actions/checkout@v2
# 使用云开发 Github Action 部署
- name: Deploy static to Tencent CloudBase
id: deployStatic
uses: TencentCloudBase/cloudbase-action@v1.1.1
with:
# 云开发的访问密钥 secretId 和 secretKey
secretId: ${{ secrets.SECRET_ID }}
secretKey: ${{ secrets.SECRET_KEY }}
# 云开发的环境id
envId: ${{ secrets.ENV_ID }}
# Github 项目静态文件的路径
staticSrcPath: public仓库私钥
设置
SECRET_ID
,SECRET_KEY
和cloudbase的ENV_ID
自动部署操作
deploy.sh
1
2
3hexo clean --config source/_data/next.yml && hexo g -d --config source/_data/next.yml
git add . && git commit -m "update public"
git pull && git push
3.4 腾讯云cdn桶
1 | deploy: |