What is it?

Obsidian Publish is a paid service, which takes the Obsidian Vault (or parts of it), generates static websites from it and then hosts them online for anyone to look through it.

My version

I like the idea, but I don’t feel like having my notes on someone else’s cloud. Therefore, I searched for a solution, which would be self-hosted. There are a couple of options, but I settled on Quartz.

I will use own Forgejo instance to hold the NoteVault data. It will serve both as a backup solution and a place to run Quartz from. Forgejo Actions will build the sites and then use SCP to copy the data to a VM running Caddy. That will in turn serve the site.

Setup

  1. Create a repository on GitHub, GitLab or other service
  2. Push your Vault to the repository
  3. Enable Actions
  4. Add Actions secrets to your repository - SSH_PRIVATE_KEY, SSH_HOST, SSH_PORT, SSH_DESTINATION_FOLDER and SSH_USER
  1. Use the CI script I put bellow (it uses SSH and rsync to deploy the site to my VPS with Caddy). I use Forgejo, so it went into .forgejo/workflows folder.
  2. Push vault with changes.
  3. It should automatically build the site and copy files over to the VPS.
  4. Setup Caddy (or Apache, nginx, etc.) to serve the files
  5. Open the URL and check if it works!

Script

name: Deploy Obsidian Vault using Quartz to Caddy

on:
  push:
    branches:
      - main # Change to the branch you want to follow

jobs:
  build:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
        with:
          path: vault
          fetch-depth: 0
      - name: Clone Quartz
        run: |
          git clone https://github.com/jackyzha0/quartz.git
          cp -r vault/* quartz/content
          cp -r vault/.forgejo/quartz.* quartz/
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - name: Install Dependencies
        run: |
          cd quartz
          ls
          npm ci
      - name: Build Quartz
        run: |
          cd quartz
          npx quartz build
      - name: Create SSH key
        run: |
          mkdir -p ~/.ssh/
          echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
          chmod 0600 ~/.ssh/id_ed25519
          ssh-keyscan -p ${{ secrets.SSH_PORT }} ${{ vars.VPSHOST }} > ~/.ssh/known_hosts
        shell: bash
      - name: Install rsync
        run: |
          apt update
          apt install -y rsync
      - name: Deploy to VPS
        run: |
          rsync -rave 'ssh -p ${{ secrets.SSH_PORT }}' --delete quartz/public ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.SSH_DESTINATION_FOLDER }}