Modern development increasingly leans toward mono repo architectures that centralize application code, dependencies, and templates in a unified repository. This approach simplifies collaboration, version control, and deployment—making it ideal for large-scale and maintainable web projects.
Embrace the Hybrid CMS:
A hybrid-cms approach allows you to keep WordPress’ as your back end while bypassing the default theme system in favor of a templating engine like Twig.
In your project root (mysite), install Twigit using Composer:
composer require devuri/twigitThis installs Twigit and Twig in the vendor directory.
Twigit can be configured via an mu-plugin or programmatically to locate templates in mysite/templates. For example:
// Recommended to define constants upstream for flexibility.
if (\defined('USE_TWIGIT') && true === \constant('USE_TWIGIT')) {
$twig = Twigit\Twigit::init('path/to/mysite', ['autoescape' => 'html']);
// Apply a template filter that overrides traditional theme handling.
$twig->templateFilter();
}If using Raydium, many configuration steps are already handled. Learn more here: Raydium GitHub Repository.
Create a templates directory in your project root:
mysite/
└── templates/
├── base.twig
├── header.twig
└── footer.twig
You can copy and adapt Twigit's base templates from its GitHub repository: Twigit Base Templates
Here’s a simple example of a base Twig template:
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{ title }}</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>