The Template Data Contract
A theme receives thirteen entries of already-computed single-language data: which fields always read true, why templates do not resolve language, and why a theme may not ship its own scripts.
A theme template receives a fully computed, single-language dataset, not a runtime that can query the database itself. This page lists the top-level shape of that data, a few rules that look writable but are not, and why the field documentation has to be generated by the server.
Thirteen entries at the top level. Title, Head, Styles, Class, Notice, Request, Site, Page, Navigation, Locale, ThemeContent, ThemeContentList, ThemeTextByNumber. Every one of them has a Chinese and an English description in the interface self-description, and some carry template examples — that self-description is generated by reflecting over the server's data structures (GET /api/v1/themes/api), not a second document written by hand. So there is only one way to decide "does this field exist": ask that address. A field absent from the self-description does not exist, and a guessed name raises no error, it just draws nothing.
Several real traps, all of them from "this looks like the way to write it".
Page.Navigation hands every item an Enabled, and on the theme side it always reads true — a card switched off in the console is filtered out by its owner before the list is ever handed over. So writing {{ if .Enabled }} in a template is a branch that can never be taken: no error, but it wastes a level of indentation.
Styles is this theme version's own stylesheet: the CSS assets declared in the manifest are concatenated in declaration order and pinned with the snapshot. Only when the theme files cannot be read (the directory is missing, or the digest does not match) does it fall back to the preset embedded in the binary. Those two states are deliberately different — "this version really declared no CSS" injects nothing, rather than handing you a stylesheet you never wrote and cannot remove from the theme.
Request always equals the address the visitor is looking at, language prefix included. Do not use it to derive "the site root" — for the site root use Site.HomeURL, and do not hard-code href="/": the meaning of / is "the home page in the primary language", and that is exactly how clicking a logo on an English page drops you back into the Chinese site.
Notice is usually empty on public pages; it is the mount point for preview-banner style messages, not a place for your content.
Links may only come out through values the server computed. Internal links (navigation, announcements, banners, pagination, canonical) get their language prefix added by Go, and the theme only consumes the result; media addresses (/uploads/…, /f/…) never get a prefix, because they are files, not pages under some language. Whether an image should be swapped for "the smaller tier" can also only be asked of the server — a theme must not filter "which addresses might have a derivative" itself (for example by only taking one prefix), because that judgement lives in the module that sees both the media master table and the derivative table; copying it means that when the media module later recognises another address form, the theme filters it out first, the feature quietly does nothing, and both sides' tests stay green.
Templates do not resolve language. What a language should display, what it falls back to when a translation is missing, which language dir takes — all of it is computed in Go and handed over. Once that judgement is delegated to the template, the publish gate, completeness statistics, snapshot reading and rendering each invent their own rule, and the cache digest will freeze wrong-language content under a foreign address as a persistent error.
A theme may not ship its own scripts, nor arbitrary template functions. This is not an unfinished feature but a deliberate boundary: templates are text executed on the server, so allowing injected custom functions would hand read access to site data to whoever uploaded a package. To extend behaviour, use fields already in the data contract, or ask for a field to enter the contract (which then requires the field description, the documentation and the built-in theme template to move together).
Changing the data contract touches four places at once. The struct field, the two language copies in the self-description, the struct documentation people copy from, and the built-in theme's templates. Missing one shows up as "the endpoint is sending it but theme authors cannot see it", or the reverse. So the practical advice on the theme-author side is plain: write templates against the self-description, not against guesses; after each theme version bump, compare the rendered result with the previous one — a missing field usually presents as blank space, not as an error.