WordPress sites are dynamic by design. For every page request, the server needs to run some PHP, alongside the necessary database queries to build out all assets associated with that page. Architecturally, this approach is in direct contrast to the JAMstack which champions serving sites statically via a CDN. A common approach to migrating to the JAMstack without fully abandoning WordPress (as was highlighted in a previous post) is to use it as a headless CMS via the WordPress REST API and a static site generator on the frontend. This technique means using WordPress solely for its content editing experience and shirking its rich ecosystem of themes and plugins in favor of those built into specific static site generators.
The conviction to use WordPress lies in its giant, all encompassing ecosystem of plugins and themes. Convincing users to stop using many of these features that they’ve grown to love in the spirit of speed, security and maintainability is undeniably a hard sell. Thankfully, continuing to use WordPress while benefiting from the JAMstack approach doesn’t mean only using it as a headless CMS. WordPress can be used as a static site generator in and of itself so you can still benefit from the speed and security that comes with pre-rendering your assets without giving up the power the WordPress platform provides. The principle of this approach is quite straightforward; a static site is generated at build time and utilizes serverless functions to run the entire WordPress install and build configuration; users only see the static output of your site while the full WordPress install lives on a separate hidden domain that gets run on build time. With this setup, you get the speed of a static site without having to drastically change the architecture of your WordPress setup. A caveat to continuing to use WordPress plugins with this setup is that you'll now have to check that plugins you're using are compatible with static site generation. This is because many native WordPress plugins like search and comments may require dynamic access to the database, which is not possible with this setup.
If all this sounds like magic, check out the That’s my Jamstack podcast episode featuring David Olson to learn more about this setup and how native WordPress can be made JAMstack.
Top comments (0)