A wallpaper gallery looks like a simple site: a grid of images, a download button, one page per picture. Mine has 113 pictures and 127 URLs in the sitemap. Here is what that actually costs to build and run as plain static HTML.

One data file, one build script

Every wallpaper is a row in a JSON file: id, title, category, original width and height, photographer, licence, source page. The build script reads that file and writes the whole site: the index, the six category pages, one page per wallpaper, the size guide, the credits table and the sitemap.

Nothing in the build calls a database, and the deployed site has no server-side code. Cloudflare Pages serves a directory of files. That means the site cannot fall over in a way I need to fix at 2am — the worst case is a bad build, and a bad build is visible locally before it is visible to anyone else.

Two sizes per image, not one

Each wallpaper ships three files:

  • 2670 x 1878 for the inner screen, about 690 KB
  • 1398 x 2034 for the cover, about 392 KB
  • 3840 x 2700 as a 4K master, about 1.2 MB

Each also gets two thumbnails, 960 x 675 for the open frame and 420 x 611 for the closed one. The card shows both because the closed crop is a different rectangle, not a scaled copy of the open one.

That is five derived files per wallpaper from one original. A script does it once; doing it by hand for a hundred images is how a gallery ends up with three different naming conventions and a broken image nobody notices.

lastmod should mean something

A sitemap with lastmod set to the deploy time is a promise you break every deploy. The build keeps a small file mapping each path to a date and a content signature. When a page's signature changes, the date moves. When it does not, the date stays.

Search engines are not obliged to believe lastmod, but a value that keeps changing on unchanged pages is noise, and eventually it gets ignored.

The parts that are not code

Two things take more time than the build script: checking that every photograph has a named photographer and a licence, and checking that the subject of each picture survives both crops. The second one cannot be automated away by a fixed rule, because "the subject" is a judgement about the photo, not a coordinate.

The rule I work to is written down rather than enforced by code: the subject sits outside the middle tenth of the width, because that band is where the hinge falls when the phone is open. Code does not know what the subject is. The check is two looks at two crops, and it is the slowest part of adding one image.

If you want to see the result, Best iPhone Duo is the gallery: 113 wallpapers, each exported twice, no account, no email, no paywall. The whole thing is a JSON file, a Python script and a directory of JPEGs.