Skip to main content
ComputerMinds

Building HeatSums with Astro and Sanity

I built Heat Sums, a set of free heating calculators, on Astro and Sanity. Here's how it's put together, including one shared set of energy prices that every calculator reads from.

Mike DixonSenior Mind · · 3 min read
The Heat Sums U-value calculator in a browser window, showing a wall U-value of 0.19 W/m²K that meets the 0.55 target.

Recently I've been building Heat Sums, a set of free heating calculators for people working on their own homes. It started because I sit bang in the middle of this Venn diagram.

A Venn diagram with three overlapping circles labelled DIY house renovator, heating geek and web developer, with "me" where all three overlap.


I’ve calculated a lot of u-values and every calculator I tried was either painful to use or tied to a specific vendor with a limited set of materials. So I built my own.

It was also a good excuse for an Astro and Sanity side quest, and who doesn’t love a good side quest?

What's on it

There are seven calculators live so far:

  • U-value calculator for walls, roofs and floors
  • BTU calculator for sizing radiators
  • Whole house heat loss
  • Boiler size
  • Heat pump size
  • Extractor fan size
  • Underfloor heating output and pipe spacing

A condensation risk calculator is next, and there's a growing set of articles explaining the numbers in plain English.

Why Astro

Each page is mostly words (what a U-value is, what the regs ask for, how to read your result) with a calculator in the middle. Astro suits that really well. It builds every page as plain HTML and only sends JavaScript for the interactive parts, so the guidance loads instantly and is easy for search engines to read, and the calculator works on top of it.

The calculators are plain TypeScript, with no front-end framework at all. The maths for each one sits in its own module with its own tests, separate from the page that shows it, so I can check a heat loss figure against a worked example without opening a browser. The site is hosted on Cloudflare as static files, with a small Worker that only handles the contact form.

The result is a fast site that's cheap to run, with almost nothing on the server to keep patched.

Why Sanity

Every calculator is a document in Sanity with its title, URL, intro, body copy, SEO description, icon and position in the list. The maths lives in code, and each Sanity document points at its calculator through a simple key field. So I can rewrite the copy around the BTU calculator, or fix a typo in the heat loss guidance, without going near the code, and the code can change without anyone touching content.

Each calculator also has a status of live or coming soon. That lets a new calculator appear on the site as a placeholder before it's finished, which is handy for planning and for search engines finding the page early.

The home page and the header and footer menus are editable in Sanity too, so the whole site can be run from the Studio.

Shared unit pricing

A lot of the calculators end in a cost. How much is this heat loss costing me a year? What would a heat pump cost to run compared to my gas boiler? To answer those you need energy prices, and UK prices change every quarter with the Ofgem price cap.

Rather than put a price into each calculator, there's a single energy prices document in Sanity. It holds:

  • electricity unit rate
  • gas unit rate
  • gas standing charge
  • heating oil price per litre
  • LPG price per litre
  • the dates the prices apply from and to

Every calculator reads its prices from that one document. When the price cap changes, I update it, publish, the site rebuilds and every running cost on the site is updated in one go. Right now it's set for January to March 2027, at 32.69p/kWh for electricity and 10.96p/kWh for gas.

We do the same on client sites. If a figure appears in more than one place, whether it's a price, a phone number or an opening time, it gets one home in the CMS and everything else reads from there. Editors change it once and can't miss a copy.

Have a play with the calculators at heatsums.co.uk. If you've got a site full of tools, calculators or price-driven content that needs a rebuild, we're happy to help :)