Skip to content

Boilerplate for new custom WordPress sites, automating many of my common customisations and setup steps.

Notifications You must be signed in to change notification settings

doubleedesign/doublee-wordpress-starterkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Double-E Design WordPress site starter kit

This repository contains boilerplate code, and references to more boilerplate code via submodules, for developing custom WordPress themes and plugins using a common foundation. It is intended to streamline my workflow by starting with a common set of tools and customisations that I have developed and refined over the years, and continue to do so with every new project. It is a living work-in-progress, with lots of TODOs and bits that are scrappy or not yet fully functional, but it is a solid foundation for my own work and I publish it here in the spirit of open source in case it is useful to other developers.


Prerequisites

  • Git
  • Node.js
  • Gulp installed globally (Gulp 5+ with gulp-cli 3+)
  • Local development environment set up with WordPress installed and running
  • Intermediate to advanced knowledge of WordPress, PHP, HTML, SCSS, JS, etc as it pertains to developing custom themes and plugins according to the requirements that brought you here. While a fair bit of boilerplate layout and design stuff is included for common requirements, if you don't want to write code this isn't the starterkit for you.

Common submodules

Repositories common to many sites (including those not developed by me, if available via GitHub) are included as submodules for easier updating.

Other required plugins


Initial setup

Note: If working on the starterkit itself using a fresh installation using Local By Flywheel, ensure you initialise it as multisite during the setup process in Local.

Installing into fresh WordPress install

  1. Initialise it as a Git repo
git init
  1. Create a basic .gitignore file to avoid committing pretty much anything initially (this is temporary and will be overwritten by this repo's .gitignore)
conf
logs
setup
.idea
debug.log
local-xdebuginfo.php
app/public/
  1. Do an initial commit
git add .gitignore
git commit -m "Initial commit"

For a new project:

  1. Allow pulling this repo into the non-empty install directory by adding it as the upstream:
git remote add upstream /~https://github.com/doubleedesign/doublee-wordpress-starterkit
  1. Pull in this main repo[1]
git pull upstream develop --allow-unrelated-histories --ff --strategy-option=theirs
  1. Delete the default theme folders if you haven't already
rm -rf app/public/wp-content/themes/twentytwenty*
  1. Pull in the submodules for your chosen branch with:
git submodule update --init
  1. Ensure the submodules are up-to-date with the latest commits:
git submodule update --remote

For working on the starterkit:

See the Development section below.

Footnotes

[1]. --strategy-option=theirs (equivalent to -X theirs) automatically resolves any merge conflicts preferring the files in this repo; if you're working with a fresh install, that would only be the temporary .gitignore from step 2, as intended. Skip this if you expect conflicts you want to resolve manually.


Automated setup script

For new projects, run the setup script and follow the prompts to do a find-and-replace across the client theme and client plugin boilerplates and rename the relevant files and folders with the client/project name.

::warn:: This script has not yet been updated for the WIP overhaul of the block theme. // TODO

Note: The file paths are set up for Local by Flywheel. Update them accordingly if you have a different setup.

node setup/setup.js

General manual setup steps

  1. Install ACF Pro and enter licence key
  2. Import TinyMCE settings from setup/tinymce-settings.json in your selected theme.
  3. Add logo, Font Awesome kit ID and external fonts to be loaded in the <head> in the global options in the admin (the page will be labelled with your site name)
  4. Update any cloud-hosted font paths within the client theme folder
  5. Add favicon in Settings > General Settings (the native one, where you set your site name)
  6. cd into the client theme folder and install dependencies (npm install)
  7. Update theme-vars.json in client theme
  8. Run Gulp scripts to generate stylesheets, bundle scripts, etc.
  9. Activate your child theme
  10. As needed, install Ninja Forms + extensions, WooCommerce + extensions, etc.
  11. Add client-specific screenshot.png to your child theme folder

Development

To work on the starterkit itself, follow the [Initial Setup][#initial-setup] steps above, then:

  1. Allow pulling this repo into the non-empty install directory by adding it as the origin:
git remote add origin /~https://github.com/doubleedesign/doublee-wordpress-starterkit
  1. Fetch the latest:
git fetch origin
  1. Reset local develop to match origin/develop:
git reset --hard origin/develop
  1. Delete the default theme folders if you haven't already
rm -rf app/public/wp-content/themes/twentytwenty*
  1. If appropriate, create and check out a new branch for your work:
git checkout -b my-new-feature
  1. Pull in the submodules:
git submodule update --init

Storybook

See ./storybook/README.md for details on setting up Storybook to develop and test theme components in an isolated fashion.

When switching computers or picking up development after a while

In addition to standard npm install of dependencies, here's some quick reminders of the scripts to run for the submodules and Storybook symlinks:

Update all submodules:

./update-submodules.sh

To open an admin PowerShell instance from WSL:

current_dir=$(wslpath -w $(pwd))
powershell.exe -Command "Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -NoExit -Command Set-Location -LiteralPath \"${current_dir}\"' -Verb RunAs"

Then in PowerShell, to delete and recreate the symlinks for Storybook:

cd storybook
./scripts/symlinks.ps1

The reason for deleting and re-creating them is that Git treats them as a generic file, not a proper symlink, and checking they exist will return true in that case even though they're not right. (Possibly a Windows-only issue, but it's a PowerShell script, so...)


Miscellaneous development notes

When updating theme-vars.json

  • Run gulp theme-json again
  • Run gulp variables again before running gulp theme, gulp components, gulp modules, or gulp blocks` again

Troubleshooting

  • Note that file paths in .gitmodules, .gitignore, and any future automated scripts use Flywheel's directory structure where the WordPress install is in app/public/ so may need to be updated for other setups
  • Check Node version against range in package.json (due to Gulp compatibility)
  • Make sure _variables.scss is generated before trying to generate any other styles
  • If WP is loading old colours, make sure you have updated theme.json (using gulp theme-json unless that would overwrite changes in which case update the file manually)
  • Unsupported gulp version error: You may need to uninstall and reinstall Gulp globally, and restart your terminal for the change to be recognised.

Problems with Git submodules when switching branches

Because the branches have some different submodules, you may encounter issues when switching between them and need to clean up the ones that aren't needed in the current branch. I have included a Bash script - ./update_submodules.sh - that clears the Git module cache and re-initialises the submodules for the current branch. It also checks out the latest commit for each submodule, helping ensure they stay up-to-date.


Warranty

There isn't one.

I have developed this starterkit for my own use, and written this documentation primarily for my future self. Sometimes I build a bunch of WordPress sites close together, and other times I might go 6 months between new builds, so I put all of this together for my own efficiency and consistency. In the spirit of open source, have posted it here for the benefit of other developers to pay it forward in tribute to how I benefitted from the likes of Brandon Jones's Super Skeleton and Ole Fredrik Lie's FoundationPress earlier in my career, and continue to benefit from other open source developers' work.

WordPress is no longer my full-time career and so I unfortunately cannot consistently dedicate time to this open source work outside of what directly benefits me and my clients. Suggestions, feature requests, bug reports, and general feedback are very welcome (I'd love to hear if you find this useful!) and I will endeavour to respond when I have time cand capacity, but ultimately use of this kit (including the referenced submodules) is at your own risk and the results are your own responsibility.


Contributing

Now to pivot from the "can't help ya" negativity of the warranty section above, I would like to emphasise that feedback is absolutely welcome (I just can't promise if or when I'll action it). If you do find this kit and/or its associated submodules that I developed or forked and modified useful and add features, fix bugs, improve the existing functionality, etc., I would appreciate it if, in the spirit of open source, you would contribute it back via pull request in the relevant repository (i.e., either here or in the submodule's repo).

If you are not able to make the change yourself, please feel free to raise the suggestion / report the bug by creating an issue in the relevant repository.

Thank you for reading, thanks in advance for any contributions or feedback you may have, and happy coding!

About

Boilerplate for new custom WordPress sites, automating many of my common customisations and setup steps.

Resources

Stars

Watchers

Forks

Packages

No packages published