Keeping your site up to date with Deploy Hooks
Fetching at build time means new posts only appear when your site rebuilds. You don’t want to trigger that by hand every time. A deploy hook does it for you: theStacc sends a request to your hosting platform whenever a post is published or unpublished, which kicks off a fresh build that pulls in the latest content. You’ll find the Deploy Hook field right below your API key, under Content > Settings > Publishing > API Access. Paste the deploy hook URL from your Cloudflare Pages, Vercel, or Netlify dashboard, click Save, then click Test to confirm it triggers a build. The URL must be an HTTPS URL. For the full walkthrough — getting the URL from each platform, GitHub Pages via GitHub Actions, and troubleshooting — see Deploy Hooks.Generating a sitemap
A sitemap helps Google discover and re-crawl your posts. The Public Blog API has a dedicated, lightweight endpoint built for exactly this:slug, published_at, and updated_at for every published post (up to 5,000 posts), so it’s fast and cheap to call during a build. Loop over the results to emit <url> entries for your sitemap.xml, mapping updated_at to <lastmod>. Full response shape is in the Public Blog API sitemap reference.
If your generator already produces a sitemap that includes your blog routes (such as @astrojs/sitemap), you don’t need to call this endpoint separately — the blog pages are picked up automatically because they’re static routes.
Testing locally
Run your site locally with the environment variables set, then verify:- The blog listing page shows all published blogs
- Each blog detail page renders content correctly
- Images load properly
- Meta tags are set (check with View Source)
- Internal links within blog content work and point to real, published posts
- A non-existent slug returns your 404 page (not a crash)
- The build fails cleanly if you set a wrong API key — confirming your error handling works
Next steps
- Review the Public Blog API reference for every endpoint, parameter, default, and limit
- Set up Deploy Hooks so your site rebuilds automatically when blogs are published
- Add an XML sitemap for SEO using the sitemap endpoint
