Zum Hauptinhalt springen
  1. Blog/

Migration von Wordpress auf Hugo

thumb-migration-von-wordpress-auf-hugo.jpg

Da ich schon immer mal einen Static Site Generator ausprobieren wollte, habe ich meinen privaten Blog kurzerhand in eine Hugo installation mitsamt Congo Template umgebaut.

Habe dazu ein paar Posts vom alten Blog händisch migriert und gleich noch ein wenig angepasst. Kommentare gibt es keine mehr, somit sind das wirklich schlanke statische Seiten, die da auf dem Server liegen.

Ich muss schon sagen, der Workflow, Markdown zu schreiben und via GitHub Action automatisch auf den Server zu deployen, hat schon was.

Die dazugehörige GitHub Action ist auch recht überschaubar:

name: Publish Blog

on:
  push:
    branches:
      - main

jobs:
  build-deploy:
    runs-on: ubuntu-latest
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
      cancel-in-progress: false

    steps:

      - name: Git checkout
        uses: actions/checkout@v3
        with:
          submodules: true
          fetch-depth: 0

      - name: Read .env
        run: |
          . ./.env
          echo "HUGO_VERSION=${HUGO_VERSION}" >> $GITHUB_ENV                    

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '${{ env.HUGO_VERSION }}'
          extended: true

      - name: Cache Hugo
        uses: actions/cache@v3
        with:
          path: /tmp/hugo_cache
          key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
          restore-keys: |
            ${{ runner.os }}-hugomod-                        

      - name: Build Blog
        env:
          TZ: 'Europe/Berlin'
        run: hugo --minify

      - name: Install SSH Key
        run: |
          mkdir -p "$HOME/.ssh"
          echo "${{ secrets.DEPLOY_SSH_KEY }}" > "$HOME/.ssh/id_ed25519"
          sudo chmod 600 "$HOME/.ssh/id_ed25519"          

      - name: Adding Known Hosts
        run: ssh-keyscan -p ${{ vars.DEPLOY_SSH_PORT }} -H ${{ vars.DEPLOY_HOST_IP }} >> ~/.ssh/known_hosts

      - name: Deploy with rsync
        run: rsync -avz --rsh='ssh -p${{ vars.DEPLOY_SSH_PORT }}' --delete ./public/ ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST_IP }}:${{ vars.DEPLOY_PATH }}

      - name: Remove SSH Key
        run: sudo rm -f "$HOME/.ssh/id_ed25519"

Wieder ein Wordpress Blog weniger, das bemuttert werden will 😈.

Foto von Luca Bravo auf Unsplash