Pre-build homepage on Netlify, with content from a headless API?

I’m developing this site:

On page load, it fetches content from the backend (Undeniable - Grist) and inserts it as HTML into the page. When you click on any of the posts (e.g., it does the same thing — it looks for the record with the corresponding slug, and renders HTML based on the page_content in the record.

I am trying to do the following:

  1. I would like the main page of the site to be pre-built — so instead of needing to load all of the text and images from the backend when the page is accessed, the pre-built HTML is immediately rendered and served. This could include automatically building a static/images folder, so all of the images from records in the backend could be fetched internally.

The building should be triggered when a new post is added to the backend with a live tag equal to 1 — and if this is difficult to do, it could also be triggered manually (e.g. in the Netlify cli or the Netlify admin interface).

Can someone recommend a way to do this?

I am thinking about using on-demand builders for the blog pages themselves (e.g., but for the main page, I think this should be pre-built and rendered.

This got posted without the body somehow, here is what it meant to include:

I’m building a Netlify content site, where the home page content is based on a headless API — when you visit index.html, it loads all the post from the backend and renders them in the display.

I would like it to do the following:

  1. On a trigger, the Netlify site builds a version of index.html, by fetching content from backend and doing a build based on that content
  2. When people visit index.html, the site will load the already built version of the home page — instead of requiring a trip to the backend.

I could imagine the trigger being a webhook (e.g. when a feature flag in the backend is set to production on a new piece of content), but it could even just be manually triggering builds and deploys in the Netlify admin interface for now.

Can somebody explain how I could do this with Netlify, if possible?

This isn’t a Netlify issue per-se. This is how most modern frameworks work, and by taking a look at your site, it appears you’re not using any frameork. It then becomes your responsiblity to build the HTML files and deploy it to the CDN.

Without us being familiar with your setup and project (we don’t intend to be, we do not provide code-level support), it’s not possible for us to guide you how to make your code build the page. You can most definitely use On Demand Builders if you can build the page within 10 seconds, or you can write a Node.js or bash scrip that would fetch the contents from your backend during the site’s build stage and build the HTML for you. Again, this would highly depend on how your setup is configured, which we cannot see or comment on.