A headless CMS (content management system) is a type of CMS that allows you to manage and store your content separately from the front-end, or “head,” of your website or application. Instead of providing a built-in front-end, a headless CMS provides a back-end API (Application Programming Interface) for developers to use when building the front-end of their website or application.

Headless CMSs are typically built using modern web technologies such as JavaScript, and can be integrated with a wide variety of front-end frameworks and libraries. This allows for greater flexibility and scalability, and makes it possible to create high-performance, engaging user experiences across multiple platforms and devices.

Because of its flexibility, a headless CMS has become a popular choice for businesses that want to build a PWA, mobile apps, or even IoT devices. This is because a headless CMS allows you to manage your content in one place and then distribute it to multiple channels and platforms.

Some examples of headless CMSs include:

  • Contentful
  • Strapi
  • Directus
  • Prismic
  • Sanity

It’s worth to mention that headless CMS is not the only approach to build a website or an application, depending on the use case and the team available, a traditional monolithic CMS can be a better choice, or even a static website generator like Gatsby.

How to build Headless WordPress

Building a headless CMS using WordPress involves several steps:

  1. Install and configure WordPress: The first step is to install WordPress on a server or hosting platform and configure it according to your needs. You can install it locally or on a web hosting provider.
  2. Install a plugin to add REST API support: WordPress has its own REST API, but you may need to install a plugin like “WP-API” to enable it. This plugin allows you to access your WordPress content via REST API endpoints.
  3. Create custom endpoints: You can create custom endpoints to retrieve specific content, by using the “register_rest_route()” function in your plugin or theme.
  4. Retrieve data from the API: Once you have the API endpoints set up, you can retrieve the data from the API using JavaScript or any other programming language that can make HTTP requests.
  5. Build the front-end: Once you have the data from the API, you can use any front-end framework or library to build the front-end of your website or application. You can use React, Angular, Vue, etc.
  6. Connect the front-end to the API: The final step is to connect the front-end to the API endpoints you created in step 3. This can be done using JavaScript libraries like axios, fetch, or superagent, or by using a front-end framework like Angular or React which has built-in support for making API calls.

It’s worth to mention that WordPress is not the only option to create a headless CMS, you can use other CMS like Drupal, or even use a pure API approach, like using Node.js, Express and MongoDB, in order to build a custom CMS.