Versioned Wordpress theme with Webpack build and Github Actions workflow to deploy to your hosting.
This is a low-fi boilerplate to start developing a wordpress theme with versioning and automated deployment. In the following you will find a description on how to setup and use it. Hope this makes your work a bit faster and cleaner 😘
- NodeJS 14 and NPM 9
- Local Apache, MySQL, PHP Stack (eg. MAMP)
- Wordpress
- Hosting with SSH Access (Wordpress already installed)
- Empty Github repository
Fork this repository.
cd your-wp-root-folder/wp-content/themes
git clone git@github.com:moritzgvt/versioned-wordpress-starter.git
npm install
npm run start
Make changes and commit them. If you want to add additional folders, you need to add them in the Webpack config file
Create an empty theme folder inside the themes folder on your hosting (eg. my-theme
)
REMOTE_PRIVATE_KEY
- Generate a new ssh key pair.
- Place the public key on your hosting side (eg. in
~/.ssh/authorized_keys
). - Use the private key for the Github repository secret.
Warning: The key has to be an RSA Private Key: It begins with
-----BEGIN RSA PRIVATE KEY-----
Use this command for creation on unix systemsssh-keygen -m PEM -t rsa -b 4096 -C "your_email@example.com"
REMOTE_HOST
The host you're connecting to via SSH.
REMOTE_USER
The SSH User you're given by your hosting provider.
REMOTE_PORT
Normally 22
.
REMOTE_TARGET
The path to your wp theme folder, normally something like this:
html/worpdress/wp-content/themes/my-theme
Go to your Github repository and trigger the deployment in the Actions
tab.
After the first successful workflow run you can log into your Wordpress instance and activate the theme.
If links are not working go to Settings > Permalinks
and save your desired settings.
Note: If you're having regular changes it might make sense to have some kind of staging where the deployment goes. And a hoster-side plublishing process.