Writing

Running eight storefronts from one Shopify theme

2 min readshopifyarchitecture

When several country storefronts share one theme, the hard part is not the shared code. It is deciding where the differences live. I led frontend delivery on a multi-country migration with eight storefronts [VERIFY: confirm the count], and this post is about the way I reason about that split. [TBD: confirm which details below match the real project before publishing.]

Keep the theme boring#

The theme should know nothing about any single country. If a section needs if country == "FR", the section is doing a job that belongs somewhere else. I try to keep every section able to render on any storefront with the same code, and let the data change what it shows.

Put differences in settings and data#

There are three places I reach for, in this order:

  • Theme settings and section settings, for things an editor changes per storefront.
  • Metafields and metaobjects, for structured content such as a shipping note or a legal block.
  • Locale files, for every piece of text.

That order matters. A setting an editor can change is cheaper than a metafield, and a metafield is cheaper than a code branch.

Branch on capability, not on country#

Sometimes code really must differ. When it does, I branch on a capability instead of a country name:

{% if settings.show_gift_message %}
  {% render 'gift-message' %}
{% endif %}

The setting says what the storefront can do. Whoever reads the template later does not need a list of countries in their head, and a ninth storefront does not need a code change.

Make the shared parts easy to trust#

A shared codebase raises the cost of a mistake, because every storefront gets it. So I want small, reviewable changes and a habit of checking more than one storefront before something ships. [TBD: describe the real review and release process, if I want to claim one.]

What I would write down early#

Before the second storefront, write down which differences are allowed and where each kind lives. It is a short list, and it saves a long argument later. When someone asks for a one-off tweak for one country, the list tells you whether it is a setting, a metafield or a real exception.

More writing