Trigger Build for a Headless WordPress and Gatsby

On our latest post we talked about how the new Quema Labs redesign is a Headless WordPress and a new Gatsby site.

This means that every time a new post like this one is published, we have to run a new build for our site to create a new static files from this post. Same goes for every new content on our WordPress site.

If you don’t update your site often, you can just trigger manually a new build directly on your static web hosting like ZEIT Now or Netlify.

But if you are like me and you love to automize things, then keep reading because I will show you how to use a new WordPress plugin to trigger a webhook on your server to start a new build every time a post, page or custom post type is edited or published on your site.

I created a new plugin called WP Headless Trigger, you can go to the Github page and download the latest release.

This is a simple WordPress plugin that triggers a webhook you specify that then will trigger your build command.

So, first download the latest ZIP file from Github, then go to your Admin Panel on your WordPress site, Plugins > Add New > Upload Plugin

Select the ZIP file, install and activate the WP Headless Trigger plugin.

Once you did that, you will see a new page under Tools > Headless Trigger on your menu.

There you have only one input to add your Webhook.

The webhook URL depends on your hosting provider, for example here in Quema Labs we use ZEIT Now. So let’s see where to find our webhook to trigger a new build.

Go to your ZEIT Now dashboard, select your project and go to Settings

There you can create a new Deploy Hook, this is a URL that each time you make a HTTP request it will run a new build script on your project.

Since we are using Gatsby, every time you run a new build, it fetch all the new data from our Headless WordPress and creates the new static files that are served on our site.

So, copy that URL and paste it on the settings page from our plugin WP Headless Trigger and click Save Changes

That’s it, now every time you edit or publish a new post, page or custom post type item, it will trigger that webhook and start a new build script.

This plugin makes even easier to run a Gatsby site with WordPress as a Headless CMS.

How To Arrange WordPress Posts in Any Order

WordPress is a high-end content management system that auto-arrange the posts based on the publish date or updated post date. However, many WordPress users find it extremely difficult to put the existing post in order.

The advanced algorithm follows the date and time of the published posts and you cannot change the order magically. Of course, there aren’t any features on the platform that assists to change the order of the posts.

Read more

5 Common WordPress Security Issues

One of the first things a budding online entrepreneur will realize is that the content management system WordPress is the most massively used website building tool on the planet. The second thing this newbie entrepreneur will likely stumble across is more than a few disgruntled users claiming its security features are crap. Don’t let these naysayers scare you away.

Read more

How to Show Different Menus to Different WordPress User Roles?

It becomes really difficult to manage different user roles on the website. If you are one from those who are running forum or a membership website then you might come across certain situations where you wish to show different menus to different user roles. The things can become really simpler if you are working with WordPress. Though there are a number of plugins that can help you out with this, but WordPress provides you capabilities to manage the user roles efficiently by default.

Read more


Subscribe to our newsletter and receive theme updates and our latest news straight into your inbox.

And you’ll receive an exclusive tutorial for your WordPress site on:

How to change your login URL