Files
supabase/apps/docs/style-guide/templates/explainer.md
Miranda Limonczenko 6649b95e87 docs: add the explainer template to the style guide (#53751)
## Problem

The style guide's template router has only the how-to guide template.
Concept pages have no structure to follow, so explainers vary widely and
many mix in procedures.

Closes DOCS-1610

## Solution

- Add `apps/docs/style-guide/templates/explainer.md`, 88 lines.
- Change the explainer row in the document-type table from
_Instructions_ to _Procedures past two steps_, to match the
tiny-procedure rule.
- Add a heading rule to the _versus_ entry in `WORD_LIST.md`.
- Add title rules to `03-page-structure.md`: name the product when the
noun alone is ambiguous, and avoid placeholder words like
_Fundamentals_. Add a Sidebar label section, since `sidebar_label`
wasn't documented.
- Add its row to the [Choose a
template](https://github.com/supabase/supabase/blob/docs/explainer-template/apps/docs/style-guide/03-page-structure.md#choose-a-template)
router in `03-page-structure.md`.

Key choices:

- **Three required parts**: the value statement with an optional
cross-reference, the only text before the first heading; a first H2 that
says what the concept is; and `## Related resources`. Process,
Structure, and `Limits` or `Trade-offs` are optional, because most
existing concept pages, such as `platform/regions` and
`storage/buckets/fundamentals`, have no Process to write.
- **Tiny procedures stay inline**: a one- or two-step action that
illustrates the concept can sit in the section it qualifies. A longer
procedure, or one with prerequisites, moves to a how-to guide.
- **Cross-references by page type**: each section says where to link,
such as a how-to for a task stage and a reference for a part's details.
The value statement ends with `For how to <task>, see <guide>` when a
how-to applies.
- **Optional Mermaid diagram**: it requires `accTitle`, `accDescr`
naming the nodes and connections, and a takeaway in the prose beside it,
per
[Diagrams](https://github.com/supabase/supabase/blob/master/apps/docs/style-guide/02-elements.md#diagrams).
- **Worked example**: a cut-down `auth/architecture.mdx` that shows
every slot. Its Process section is illustrative.

The skills reach templates through the router, so no skill file changes.

### Learnings from the first rework

These refinements come from reworking ten explainers in #53755 and
#53757:

- **No concept heading.** All five pages define the concept in their
opening paragraph, so a `## What <concept> is` heading would repeat it.
Later reversed: see Engagement rules.
- **One H2 per part.** `auth/architecture` gives each layer its own
section, and other pages link to them. The template now allows a parts
table followed by one H2 per part.
- **Linked headings keep their text** in whichever slot they fill, such
as `## Public vs private buckets` as Trade-offs.
- **Principles have a home**, such as "treat the schema as read-only":
in Limits or Trade-offs, or as an admonition that leads with its impact.
- **Related resources can repeat the how-to link** from the value
statement. Every page did, and the link-once rule contradicted the
example.
- **When to use.** An optional `## When to use <concept>` section
answers the reader question's "when do I use it?" Two pages had one and
no slot fit.
- **Bigger Process and Parts.** A Process can take one H2 per stage, for
`realtime/architecture`. A concept with two independent sets of parts,
such as index types and distance operators, gets one section for each.

### Engagement rules

These rules make explainer sections easier to skim, from a read of the
reworked Auth architecture page:

- **Each part leads with its job**, then says when the reader works with
it. History goes last or is cut.
- **A Process follows one real case** with real names, such as the
endpoint a sign-in calls.
- **A diagram stays on the concept**, or the prose names the path that
matters.
- **Only the value statement before the first heading.** The concept
opener slot is gone. The page opens with what the reader can decide and
an optional cross-reference to a sister page, and the first H2 says what
the concept is, so the definition sits under a heading a reader can scan
to.
- **Comparison headings are `X vs Y`.** Most existing guide headings
already use it, such as `## JSON vs JSONB`. `WORD_LIST.md` now says so
under _versus_, and prose keeps _versus_.
- **Tables and lists come first.** Comparisons on shared attributes go
in a table and parallel facts go in a list, with prose kept for the
reasoning that connects them.
- **One optional everyday-life analogy**, such as a music festival for
Auth. It's framed as a comparison, with _like_ or _similar to_, because
no analogy is exact. It names only the one or two pieces that connect
it, so the reader gets a mental model rather than a second explanation,
and it comes after the literal explanation, so it doesn't conflict with
[Avoid idioms and
colloquialisms](https://github.com/supabase/supabase/blob/master/apps/docs/style-guide/01-voice-and-tone.md#avoid-idioms-and-colloquialisms).

To read the whole stack in one diff:

```bash
git diff master...docs/explainer-rework-batch-2
```

### Preview

The style guide isn't served on the docs site, so these link to the
rendered files on the branch.

| File | Preview |
| --- | --- |
| Explainer template |
[`templates/explainer.md`](https://github.com/supabase/supabase/blob/docs/explainer-template/apps/docs/style-guide/templates/explainer.md)
|
| Template router |
[`03-page-structure.md`](https://github.com/supabase/supabase/blob/docs/explainer-template/apps/docs/style-guide/03-page-structure.md#choose-a-template)
|

## Review instructions

1. Open `apps/docs/style-guide/templates/explainer.md` and check that it
is 90 lines or fewer.
2. In `03-page-structure.md`, check that the explainer row in **Choose a
template** links to the new file.
3. Pick a concept page, such as `content/guides/platform/regions.mdx`,
and check that the template fits it without padding.

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-11-23 09:41:47 -08:00

89 lines
9.3 KiB
Markdown

# Explainer template
**Category:** Concept content.
**Reader question:** "What is it, and when do I use it?" A Concept, with a Process, a Structure, and a Fact ([Information types](../03-page-structure.md#information-types)), and no procedure past two steps.
An explainer covers one concept: the reader leaves able to say what it is, how it works, and when to use it. Split when a section grows its own subsections and shares little with the rest of the page beyond the subject word. That section is a second concept, so give it its own page and link to it. A one- or two-step action that illustrates the concept can sit in the section it qualifies: a sentence for one action, a numbered list for two. A longer procedure, or one with prerequisites, belongs in a how-to guide, so link to it.
## Frontmatter
- `title`: a noun phrase, 35 characters or fewer, such as `Auth architecture`. Name the product when the noun alone is ambiguous, per [Title](../03-page-structure.md#title).
- `description`: one sentence of 150 to 160 characters naming the concept and what the reader learns.
## Headings, in order
Keep this order for the sections the page has. A short page can be only the required three. Link once per target, and only where it helps, per [Connect contextual sections](../03-page-structure.md#connect-contextual-sections-to-their-procedures). A heading that other pages link to keeps its text in whichever slot it fills. A section that compares two named things is `## <X> vs <Y>`, per [versus](../WORD_LIST.md#versus).
**Tables and lists come first.** Readers scan an explainer before they read it, so in every section, turn prose into a table or list wherever it fits. Things compared on the same attributes, such as two options or a set of status values, go in a table, per [Tables](../02-elements.md#tables). Three or more parallel facts go in a list. Keep prose for the reasoning that connects them.
1. **Required**: Value statement, no heading, in one or two sentences. What the reader can decide once they understand the concept, such as `Knowing <concept> tells you <decision>`. If a sister page applies the concept, end with a cross-reference, such as `For how to <task>, see [<guide>](link).` Nothing else comes before the first heading.
2. **Required**: The first H2 opens with one sentence that says what the concept is. It can be the Process or Parts section below, or its own section. Name it for what it covers, such as `## How Storage assigns an owner`, or use `## Overview` when the section introduces the concept in general. Link the first mention of a related concept to its explainer.
3. **Optional**: `## How <concept> works`: a Process as stages in order, or a when/then table. Include it if the concept has stages. Follow one concrete case through the stages, with real names, such as the endpoint a sign-in calls and the table it reads. When a stage needs more than a paragraph, give each stage its own H2 instead. Past about five such stages, group them under shared H2s with an H3 per stage, per [Grouping sections](../03-page-structure.md#grouping-sections). Link a stage that is a task to its how-to guide.
4. **Optional**: `## <Parts>`: a Structure as a table of each part and what it does, one row per part, each a verb phrase. Name it for the parts, such as `## Layers` or `## Tables`. A concept with two independent sets of parts gets one section for each. When a part needs more than a row, follow the table with one H2 per part. Past about five such parts, group them under shared H2s with an H3 per part, per [Grouping sections](../03-page-structure.md#grouping-sections). Open each part's section with its job, then say when the reader works with it. History, such as what a part was forked from, goes last or is cut. Link each part to the page that covers it: an explainer for the idea, a reference for the details.
5. **Optional**: `## Limits` or `## Trade-offs`: Facts a reader needs to decide. Use `Limits` for hard numbers and `Trade-offs` for what the concept costs. A principle, such as `treat this as read-only`, can go here or ride along as an admonition that leads with its impact. Link the reference page that has the full list.
6. **Optional**: `## When to use <concept>`: when this concept is the right choice over an alternative, as a list of use cases or a comparison.
7. **Required**: `## Related resources`: any how-to guide that applies the concept first, then a tutorial, explainers, and reference pages, each with a reason. It can repeat the value statement's how-to link. Last on the page.
**Optional**: a Mermaid diagram in the Process or Structure section it supports, per [Diagrams](../02-elements.md#diagrams). Make it accessible:
- State the takeaway in the prose beside it, so the page works without seeing the diagram.
- Put the diagram type, such as `sequenceDiagram`, on the first line. Follow it with `accTitle`, one line naming what it shows, then `accDescr`, naming the nodes and how they connect. Keep to one flow, with no hardcoded colors.
- Scope it to this concept. An existing image that shows more, such as the whole platform, needs the prose to name the path that matters.
**Optional**: one analogy from everyday life, such as nature or music, after the literal explanation it illustrates. Pick a scene most readers have seen firsthand, so it gives them a mental model. Frame it as a comparison, with `like` or `similar to`, never as an equivalence. Name only the one or two pieces that connect it to the concept, and let the scene carry the rest. If a difference would mislead, say where the comparison stops matching. Spell it out in plain words, per [Avoid idioms and colloquialisms](../01-voice-and-tone.md#avoid-idioms-and-colloquialisms). The page still works without it.
## Example
Worked from [Auth architecture](/docs/guides/auth/architecture), cut down to show every slot. The Process section is illustrative.
````md
---
title: Auth architecture
description: Learn how Supabase Auth is built from four layers, how a sign-in request moves through them, and what each of the layers is responsible for in your project.
---
Knowing the layers of Supabase Auth tells you where a failed sign-in is happening. For how to sign in a user with a password, see [Password-based Auth](/docs/guides/auth/passwords).
## How a sign-in works
Supabase Auth is an API server that issues JWTs and stores users in your Postgres database. To sign in, the client SDK sends the email and password to `/auth/v1/token`. The gateway routes the request to the Auth service, which checks the password against `auth.users` and returns a JWT.
```mermaid
sequenceDiagram
accTitle: Sign-in request path
accDescr: The client sends a sign-in request to the API gateway, which routes it to the Auth service. The Auth service returns a JWT to the client.
Client->>Gateway: Sign-in request
Gateway->>Auth: Route request
Auth-->>Client: Return JWT
```
Like a music festival, Supabase Auth hands out something similar to a wristband: a JWT that each service checks instead of calling the ticket booth. Like a day's wristband at a weekend festival, it expires, and the client trades its refresh token for a fresh one.
## Layers
| Layer | What it does |
| ------------------------------------------------- | --------------------------------------------------------------- |
| [Client](/docs/reference/javascript/introduction) | Makes HTTP calls and stores tokens |
| Gateway | Routes each request to the right service |
| Auth service | Validates, issues, and refreshes [JWTs](/docs/guides/auth/jwts) |
| [Postgres](/docs/guides/database/overview) | Stores users in the `auth` schema |
## Related resources
- [Password-based Auth](/docs/guides/auth/passwords): the task this architecture serves.
````
## Not recommended and Recommended
- **Not recommended**: A diagram with no `accDescr`, or one that restates the title. **Recommended**: A description naming each node and connection.
- **Not recommended**: A paragraph walking through what happens for public buckets, then for private buckets. **Recommended**: A table with a column for each bucket type and a row for each attribute.
- **Not recommended**: `The Auth service is a fork of GoTrue, originally created by Netlify.` **Recommended**: `The Auth service issues and refreshes your users' JWTs. You work with it when you add a sign-in method.`
## Checklist
- [ ] One concept, no procedure past two steps, and a value statement naming what the reader can decide, ending with the how-to link when one applies.
- [ ] Only a value statement and an optional cross-reference before the first heading, and the first H2 says what the concept is. Then each section the concept needs, in order, with subsections only to group parts or stages. Any diagram has `accTitle`, `accDescr`, and a takeaway in the prose beside it.
- [ ] Every comparison is a table and every set of parallel facts is a list. Each part opens with its job, a Process follows one real case, and any analogy is framed as a comparison and names only the pieces that connect it.
- [ ] Links go to the page type that serves the reader: how-to for steps, reference for details. Related resources come last, each with a reason.