前言

又到了折腾博客的时候了,之前的hexo博客,因为每次build很慢,而且到了mac环境,各种出错,懒得修复了,不如重新搞一套。调研了一下,hugo满足我的需求,然后花了一个周末迁移成功。

主题

主题是基于hugo-theme-yinyang定制,添加以下特性:

  • 搜索
  • 分类
  • 分页
  • baidu收录
  • 文章底部自动版权说明
  • 打赏

部署

之前hexo使用的是git webhook,这次使用的git actions,每次push,自动部署的到服务器。

name: DEPLOY

on:
  push:
    branches:
    - master

jobs:
  build-deploy:
    runs-on: ubuntu-18.04
    
    steps:
    - name: Checkout
      uses: actions/checkout@master
      with:
        submodules: recursive

    - name: Setup Hugo
      uses: peaceiris/[email protected]
      with:
        hugo-version: 'latest'

    - name: Build
      run: hugo

    - name: Setup Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.7'
        architecture: 'x64'

    - name: Search
      run: pip install -r requirements.txt && python algolia.py

    - name: Deploy
      uses: appleboy/scp-action@master
      env:
        HOST: ${{ secrets.HOST }}
        USERNAME: ${{ secrets.USERNAME }}
        PORT: ${{ secrets.PORT }}
        KEY: ${{ secrets.KEY }}
      with:
        rm: 1
        source: "public"
        target: "/root/projects/Blog"
        strip_components: 1