Create your own blog with Hexo + GitHub Actions

Why have your own blog?

There are many platforms on the market for us to write blog, such as: Jianshu, CSDN, nuggets…

So as a new youth with ideals and aspirations, why do you want to have a blog of your own?

Yes, is love toss!!

Hahaha, that was the beginning of the purpose of this blog.

Why hexo?

I actually started blogging with wordpress, but I didn’t feel comfortable with it. Just use the static blog Hexo.

Typecho was something I wanted to consider, but it seems like the official version hasn’t been updated for a long time and is more difficult to configure than wordpress (although Hexo isn’t easy to configure either), so I decided to drop Typecho and use Hexo blog instead.

More importantly

Yunyunjiang wrote a hexo blog on the Theme of hexo-theme-yun, so it was used!!

Love Yunyun (no)

Specific configuration

  1. First, you need to go to the Hexo website to install Hexo by following the tutorial

  2. Go to Hexo-theme-yun, follow the tutorial step by step installation and follow the documentation inside

  3. I’m using GitHub Actions for automatic packaging and FTP upload to the server. The path is. Making/workflows/deploy. Yml please new (there is no corresponding folder or file). GitHub Actions configuration is as follows:

name: Deploy

on:
  push:
    branches:
      - main

jobs:
  build:
    name: 🍳 Build on node The ${{ matrix.node_version }} and The ${{ matrix.os }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        os: [ubuntu-latest]
        node_version: [16.x]

    steps:
      - name: 🤔 Checkout
        uses: actions/checkout@v2
      
      - name: 🚚 Install dependencies
        run: | npm install
      - name: 🎉 Deploy hexo
        run: | npm run deploy
      - name: 📂 Sync files
        uses: SamKirkland/[email protected]
        with:
          server: The ${{ secrets.ftp_server }}
          username: The ${{ secrets.ftp_username }}
          password: The ${{ secrets.ftp_password }}
          local-dir: ./public/
          server-dir: /wwwroot/lkzstudio/www/
Copy the code

Note: The last three parameters are added in your GitHub repository Settings -> Secrets -> Actions -> New Repository secret

  1. After submitting your project to the server with git push, GitHub will automatically execute GitHub Actions and upload it to your server

  2. Resolve the domain name and bind the FTP upload server, and you’re done!