With a headless WordPress site you can have separate back and front ends. With this, you can generate static copies of your WordPress site which will load the site much faster.
In this tutorial, I will show you how to make a headless WordPress setup. Then I will show you how to serve the site with the help of AWS.
Headless WordPress Introduction
In a traditional WordPress setup, when you make changes on the back end (wp-admin dashboard), you see the changes on the front end. In this setup, WordPress serves both the front and back ends.
In a headless setup, WordPress is not used to generate the front end of your site. It only acts as a back end. For the front end, we can use any other platform that connects via WordPress API or we can set up a static website.
For this article, we will set up a static website since that is the most common headless setup.
Advantages of static sites:
- Static sites are highly secure as the back end and front end is isolated.
- Static sites are non-dynamic – meaning they don’t need to pull information from the database or execute scripts. Hence, they are blazing fast.
- Static sites are more economical as more people can be served with a less powerful server.
However, this approach may not work on all types of sites. For example, eCommerce sites are dynamic in nature. So, running a headless site is impossible. But, for most sites, headless approach will work out just fine.
ALSO READ: How to Install WordPress on AWS Lightsail
Time needed: 15 minutes.
How to Set Up a Headless WordPress site in a few steps
- Sign up to AWS
Sign up to AWS as we will be using AWS S3 to serve our site statically. Also, you will get 12 months for free.
- Generate a static copy of your site
For this, you need a WordPress installation somewhere. You can install WordPress on your local computer too! You can achieve this by:
1) Using XAMPP
2) Using Local by Flywheel
Next, download WP2Static, configure everything and select Amazon S3 from the list.
- Connect to AWS
After you select Amazon S3, some new fields will appear. Find out your Access ID and Secret and enter them into the respective fields. Once you have done that, select the AWS region in which your bucket was created. Once you have done that, scroll down and select Start static site export button.
After the transfer has completed, you should be able to access the live static version of your site.
I hope this tutorial has helped you. If you have any queries or suggestions, then please let me know in the comments down below.
ALSO READ: 10 Ways to Secure Your WordPress Site
Subscribe to the newsletter to get curated WordPress resources right into your mailbox!