After trying to to deploy to GitLab Pages and GitHub Pages I decided to deploy to my own server as neither of those providers fit my needs, because:

First of all, I’d like to remind you that this is not necessary and that for most people those providers mentioned above will probably be good enough. They even support custom domain names.

Second of all, my goal is to keep my setup as simple as possible and focus as much as possible on writing. That means, that I of course need CI / CD setup and as I see no point of hosting my own Git server, I use GitHub and their GitHub Actions:


name: CI
on: push
    runs-on: ubuntu-18.04
      - name: Git checkout
        uses: actions/checkout@v2

      - name: Update theme
        run: git submodule update --init --recursive

      - name: Setup hugo
        uses: peaceiris/actions-hugo@v2
          hugo-version: "0.64.0"

      - name: Build
        run: hugo --minify

      - name: Deploy
        uses: appleboy/scp-action@master
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.KEY }}
          port: ${{ secrets.PORT }}
          source: "public/"
          target: "/var/www/"

This file is pretty self explaining, it runs each time I push to the repository where I have my Hugo source code and it does those steps:

  1. Check out my repository
  2. Initiate Git submodules (the theme)
  3. Install Hugo
  4. Build the site
  5. SCP the site to my server


Of course we need to also prepare the server, I created separate user with scponly shell and no password but keep in mind that this user will be reachable using RSA key storred in GitHub Secrets so it’s up to you whether you trust GitHub Secrets. Here is my setup:

# zypper ar
# zypper in scponly
# useradd -s /usr/bin/scponly -m -d /var/www/
# sudo -u ssh-keygen -t rsa
# sudo -u cp /var/www/{,authorized_keys}

Now we know all of our secrets which we need to add to GitHub Settings Secrets section:


This setup automates the building and publishing process of my site. After each push I can expect a directory in /var/www/ containg up-to-date version of my site.

I wrote a blog post about my Nginx and Certbot setup which I use to host this site.