Warning
This repository is no longer maintained by our internal teams.
The template is provided as is and will not receive updates, bug fixes, or new features.
You are welcome to contribute on it or fork the repository and modify it for your own use.
To deploy this template on Upsun, you can use the command upsun project:convert
on this codebase to convert the existing .platform.app.yaml configuration file to the Upsun Flex format.
This template builds a two application project to deploy the Headless CMS pattern using Gatsby as its frontend and Wordpress for its backend. The gatsby-source-wordpress source plugin is used to pull data from Wordpress during the post_deploy hook into the Gatsby Data Layer and build the frontend site. Gatsby utilizes the Platform.sh Configuration Reader library for Node.js to define the backend data source in its configuration. It is intended for you to use as a starting point and modify for your own needs.
Note that after you have completed the Wordpress installation, the project will require a redeploy to build and deploy Gatsby for the first time. See the included README's post-install section for details.
Gatsby is a free and open source framework based on React that helps developers build statically-generated websites and apps, and WordPress is a blogging and lightweight CMS written in PHP.
- Node.js 14
- PHP 7.4
- MariaDB 10.4
- Automatic TLS certificates
- npm-based build for Gatsby
- Composer-based build for Wordpress
- Multi-app configuration
- Delayed SSG build (post deploy hook)
- When you initially deploy the template, you will receive a
403error on the base route. There is not yet any content to build the Gatsby site, because Wordpress has not yet been fully installed. Visit thebackend.<generated url>subdomain, and run through the Wordpress installer as normal. You will not be asked for database credentials as those are already provided. - Once you have completed the Wordpress install, redeploy the environment with
platform redeploy -p <PROJECT ID> -e master.
The following files and additions make the framework work. If using this project as a reference for your own existing project, replicate the changes below to your project.
- The
.platform.app.yaml,.platform/services.yaml, and.platform/routes.yamlfiles have been added. These provide Platform.sh-specific configuration and are present in all projects on Platform.sh. You may customize them as you see fit. - Additional Platform.sh configuration reader modules for both PHP and Node.js have been added. They provide convenience wrappers for accessing the Platform.sh environment variables.
gatsby-config.jshas been modified to read the Wordpress backend url and assign it to thebaseUrlattribute for thegatsby-source-wordpressplugin. Since routes are not available during the build hook, and since we want this value to be generated and unique on each environment,gatsby buildruns and pulls in content from the Wordpress app during thepost_deployhook on the mountedpublicdirectory.gatbsby-source-wordpresscan have additional parameters set to modify your configuration, so consult the documentation.