Deploy Kirby with Git and rsync

Published

Updated

Deploy the code of a Kirby site to fortrabbit with Git, and sync the content with rsync. The Kirby software template excludes content and media from deployments, so edits made in the panel survive.

Get ready

Keep content out of Git

Add these rules to .gitignore in the project root:

# .gitignore

# Kirby itself, managed by composer
/kirby

# Composer, managed
/vendor

# To be synced by rsync not Git
# Can also be included, to keep an extra copy
# Will not be deployed (default exclude patterns)
/content
shell

Code then goes by Git, content by rsync. To keep a copy of the content in Git, leave /content out of .gitignore: the exclude patterns still keep deployments from overwriting it.

Init Git and add GitHub

Create a Git repository and push it to GitHub, for example with the GitHub CLI:

# Setup local git repo
$ git init
$ git add -A
$ git commit -am 'Init'

# GitHub CLI to create/connect remote Git repo
$ gh repo new
# Follow the steps
# Push an existing local repository to github.com
# Add as remote and assign current branch as 'origin'
shell

The repository now exists on GitHub. From here on, git add, git commit and git push send changes.

Connect your GitHub repo with fortrabbit

Create an app on fortrabbit:

Choose Kirby as the software and the repository for Git deployment, then start the first deployment. The site shows errors until the content arrives in the next step. An existing app connects the repository in its settings.

Deployment settings

The Kirby software template sets the replace strategy and excludes content, media and the panel accounts and sessions, so deployments leave them alone. The Composerkit also needs the root path public.

Environments created before October 2026 lack the two panel folders. Check the exclude patterns: without them, every deployment deletes the panel users created on the server:

/site/accounts
/site/sessions
plain

Kirby 6, 5, 4, 3

DeploymentValue
Root path(the repository root)
Deploy strategyreplace
Excluded paths/node_modules/content/media/public/media/web/media/data//site/accounts/site/sessions
Build commandscomposer install --no-dev --prefer-dist --no-interaction --no-ansi --no-progress
Post-deploy commandsrm -rf site/cache/*/pages
Environment variablesValue
APP_DEBUGfalse
APP_MODEproduction

Synchronize contents with rsync

Git deploys templates, config and the Composer dependencies. The content goes separately, with rsync. From the project folder:

# SYNC UP: from local content folder and its files to remote
$ rsync -av ./content/ {{app-env-id}}@ssh.{{region}}.frbit.app:content/
shell

Down, to get edits made in the panel on the server:

# SYNC DOWN: from files from remote content folder to local folder
$ rsync -av {{app-env-id}}@ssh.{{region}}.frbit.app:content/ ./content/
bash

SFTP works for the content folder too.

Going forward

From now on, git push deploys code changes, and rsync moves content.

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗