hexo静态博客
博客搭建部署hexo+github.io
安装初始化
1 | npm install -g hexo-cli |
创建新博客
1 | hexo new title |
监视生成静态资源
- 修改完成前监听,保存自动更新静态资源
1
hexo generate -w
启动
- 另起一个终端,开启服务,一边监视生成静态资源,一边loalhost:4000查看效果
1
2hexo server
访问localhost:4000部署到git
1
2
3
4
5
6
7
8
9
10
11配置_config.yml:
deploy:
type: 'git'
repo: git@github.com:alittlegit/alittlegit.github.io.git
安装部署工具:
npm install hexo-deployer-git --save
执行
hexo deploy // 不更新则使用下面的命令
hexo deploy --generate
或
hexo generate --deploy
更换主题
- github搜索hexo theme
1
2
3
4cd source/themes
git clone https://github.com/theme-next/hexo-theme-next themes/next
更改配置文件:
theme: next
hexo-next使用
设置分类
- next主题, _config.yml中开启相关设置
1
2
3
4
5
6
7
8
9menu:
home: / || home
#about: /about/ || user
#tags: /tags/ || tags
categories: /categories/ || th
archives: /archives/ || archive
#schedule: /schedule/ || calendar
#sitemap: /sitemap.xml || sitemap
#commonweal: /404/ || heartbeat - 按文档说明添加分类页面
1
2
3hexo new page categories
设置type类型
type: "categories"
markdown图片配置
- 使用typro+Front Matter
- 设置typro根目录为typro-root-url: ./,也可以在编辑-图片工具-设置根目录里设置后生成
- 设置图片插入时复制到指定目录: 自定义 : ./images
- 根目录在images上一级,便可以得到想要的图片路径: /images/xxx.jpg
博客部署hexo+服务器(非docker和docker)
github+git静态博客
- github: https://github.com/alittlegit/alittlegit.github.io
- hexo搭建博客,本地发布文章测试
- hexo+github.io,将静态资源部署到github上,
- 访问: alittlegit.github.io
- hexo初始及部署具体设置见上面
hexo静态博客部署到服务器:hexo+node+webhook
- github: https://github.com/alittlegit/alitllegit-github-deploy
- 在服务器项目下克隆hexo的静态资源 git clone git@github.com:alittlegit/alittlegit.github.io.git public,命名文件夹为public,gitclone的目的方便后续直接git pull
- 服务器上需要新建一个server,托管静态资源即可,pm2管理
- 通过webhook持续集成:git上托管的的hexo资源一旦push,服务器自动pull,可以及时更新
- 访问: http://onepiece.suprise.top/
hexo静态博客部署到服务器:hexo+node(docker)+webhook
- github: https://github.com/alittlegit/alitllegit-github-docker
- git clone静态资源,同上
- 新建一个pm2 docker容器,容器中开启node server
- webhook持续集成:git上托管的的hexo资源一旦push,服务器自动pull,自动重启docker,及时更新
- 访问: http://docker.suprise.top/
workflow
- 本地hexo更新文章==>hexo deploy上传git,更新静态资源==>alittlegit.github.io 文章更新
- 本地hexo更新文章==>hexo deploy上传git,更新静态资源==>webhook==>服务器git pull==>http://onepiece.suprise.top/ 文章更新
- 本地hexo更新文章==>hexo deploy上传git,更新静态资源==>webhook==>服务器git pull+”resbulid docker”==>http://onepiece.suprise.top/ 文章更新
其他
- 服务器/docker/webhook分别使用一个端口,nginx转发,webhook是设置在项目的setting中的
- 注意docker build的路径,可以指定context,ADD/COPY 文件不能超出context