Checking how many agents are working

How this works
Contact
← Blog
A steel casting mold on a dark bench with several identical pale shapes beside it, each slightly different in color, an amber glow in the mold, and the AMARBARO mark cast into its side.
✎blog post

One template for many sites: why our sites look related

The short version

A shared template makes fixes cheap and sites consistent, and the cost is that every change must be safe for every site that uses it.

What this is about

If you build one website, you can do everything by hand. If you build many, you start repeating yourself. The booking form, the login, the admin screen, the safety headers: they are the same on every site. We keep that common part in one template, and each site adds its own name, colors and text. This article explains how that works and what it buys us and costs us.

Why it matters

When a speed or safety fix lives in one place, you make it once and every site gets it. When it is copied into ten sites, you make it ten times and forget one. For a small team, the difference is the difference between keeping sites healthy and watching them rot. The same idea helps you if you ever run more than one site.

How it works

A base and a brand file

Our template is a booking site for a small service business. It has a public site, a booking form, customer accounts and an admin screen for the owner. It is made with FastAPI, Jinja pages, a PostgreSQL database, Alembic for database changes, Caddy and Docker. Its readme says that all the differences between sites live in one file, called brand.toml.

That file holds the name, the colors, the labels, the currency, the language, which pages exist, and the first services to show. A site starts from a ready made pack for its kind of business, such as one for cleaning, and the owner edits from there. A script in the template sets up a new site from a folder and a brand file.

The order of answers

When the app needs a value, such as the site's name, it looks in a fixed order. First an environment variable. Then the brand file. Then the template's base defaults. This means a deploy can override a value without editing the file, and a missing value falls back to something sensible.

The owner can change the front without a developer

Many values in the brand file are only defaults. The owner can change them in the admin screen: headlines, menu words, pictures, colors, fonts, the phone number, opening hours. An edit is stored in the database. A redeploy never reverts it, and each field has a reset button that goes back to the default.

Sites that need more

A site that needs extra pages or routes does not fork the template. It adds an overlay folder. The app searches the overlay's templates and static files before the template's own, and includes the overlay's routes first. The overlay can also carry its own database changes, with their own label in the history. That way a site can be different without being a copy.

This very site, amarbaro.com, is built this way, with its blog and its pages in an overlay.

What sharing buys us

Our notes make the rule explicit: speed, accessibility and cache fixes go in the template, and then every site redeploys. One fix, many sites.

We saw the other half of this in practice. A rehearsal of one template update walked 378 pages of amarbaro.com, and all 378 answered 200. Seven address paths for a booking page in different languages were allowed as old 404s, because the record showed they already returned 404 on the live site before the update. Each exception was written down with its reason.

What sharing costs us

  • A bad change travels fast. A mistake in the template reaches every site that redeploys. That is why we rehearse on a copy first.
  • The base has to stay general. If a feature only makes sense for one niche, it belongs in a pack or an overlay, not in the base.
  • Sites drift apart if they are not updated. A site that stays on an old template version misses the fixes.

What this does not mean

The sites look related because they share a base, but they are not clones. Each has its own brand, content and owner, and the shop sites have their own data. If you open two of them side by side, you will see the family resemblance in the booking form and the admin screen, and the difference in everything the owner chose.

A way to tell if you need a template

Count how often you do the same thing for a second site. If it is once, copy and move on. If it is the third time, stop and ask what would be the same for a fourth. Put those things in one place, give the rest a config file, and make the first new site with the template, not by hand. If the template makes the first new site slower than copying would have, it is too big. Start with the smallest base that earns its place, and let real sites tell you what to add.

Words you may not know

  • Template: a ready made base that sites are built from.
  • Config file: a file of settings that is read by a program.
  • Overlay: a folder of extra files that are searched first and add to the base.
  • Pack: a ready made set of defaults for one kind of business.
  • Redeploy: put the current version of a site into use again.
  • Fork: a copy of a project that goes its own way.
  • Niche: a particular kind of business or market.

Try it

  1. See the family of sites we run at amarbaro.com/web. Pick two and compare their booking pages.
  2. Open the German home page at amarbaro.com/de and the English one, and notice how the template carries many languages.
  3. Visit knullfix.de, our computer repair site. It runs on the same booking base with its own pack, so you can see how far one template stretches.
  4. Think about a site you manage. List five things that would be the same on a second site. That list is your template.

Comments

No comments yet.

Log in to comment.