In this blog post, I’ll share a useful hack that can simplify your life: triggering a redeploy of your site on platforms like Netlify, Vercel, or Cloudflare Pages using just a link.
When working with static sites, scheduling posts with future dates can be a bit tricky since they won’t be published until after their designated publishing date has passed. While platforms like WordPress have built-in features for this, static sites require a different approach.
Most platforms offer deploy hooks, which allow you to trigger a redeploy of your site when a specific URL is reached. However, these hooks typically listen for POST requests, making it a bit challenging to trigger a redeploy using just a link.
To overcome this limitation, you can create a hidden page on your static site with a unique and unusual URL. When this page is loaded in a browser, a script can be executed to send a POST request to your deploy hook URL, thereby triggering a redeploy. Here’s an example of how you can accomplish this with JavaScript:
const deploy_hook_url = 'https://YOUR_DEPLOY_HOOK';
fetch(deploy_hook_url, {
method: 'post',
headers: {
'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
},
});
By loading this hidden page, the POST request will be sent to your deploy hook, prompting a redeploy of your site.
Using this approach, you can easily schedule posts with future dates on static site platforms and ensure they are published at the correct time.
Tags: static site, deploy hooks, redeploy, Netlify, Vercel, Cloudflare Pages