Facet
DeutschInstall
Docs & onboarding

Build a help site from FACET that tells you when it may be out of date

Build a static product help site from your FACET recordA FACET record is a short, checkable description of one feature, kept as a YAML file next to the code. It states why the feature exists, the behaviour it promises as scenarios, and the tests that check it.In the glossary with articles you write yourself, and let facet docs site check fail whenever a record, its anchored code or your article text changed since the build.

  • 8 min read
  • 5 steps
  • npm
  • Your coding agent

The help site was written for the launch and nobody has touched it since. Since then, developers changed how discount codes expire, added a minimum order value and renamed two error codes. Nobody knows which help pages are still right, so support no longer links to them and writes the same answers by hand instead.

FACET keeps a short, checkable description of each feature, called a record, next to your code, and comments in the code, called AnchorAn anchor is a comment in the source code, starting with @facet:, that names the record the code belongs to. FACET reads these comments to know where each feature is implemented.In the glossary, link each record to the code it describes. By the end of this guide you build a small, static product help site from your FACET records, with articles you write yourself, and npx facet docs site check fails whenever a record, the code anchored to it or your article text has changed since the build. None of those can change behind the site's back without the check saying so.

The commands below use the example shop from “One answer instead of three”, which has one record for discount codes. In your own project, start with one topic that support gets asked about a lot.

Step 1Describe the site in one file

The site is defined by an editorial configuration, by default docs/site.json. It names the topics, the readers and the articles. Save this as docs/site.json:

json
{  "version": 1,  "mode": "reference",  "language": "en",  "visibility": "public",  "catalog": true,  "title": "Demo Shop help",  "description": "How cart, discount codes and checkout behave in the Demo Shop.",  "topics": [    {      "id": "checkout",      "title": "Cart and checkout",      "description": "Filling the cart, discount codes and placing an order.",      "prefixes": ["checkout/"]    }  ],  "audiences": [    { "id": "customers", "title": "Customers", "kind": "customer", "description": "People who buy in the shop." },    { "id": "support", "title": "Support", "kind": "creator", "description": "People who answer customer questions." }  ],  "articles": [    {      "id": "discount-codes",      "title": "Discount codes",      "kind": "faq",      "topic": "checkout",      "category": "Cart and checkout",      "audience": "",      "description": "When a code works, when it expires and why the shop refuses it.",      "tags": ["discount", "coupon", "voucher"],      "features": ["checkout/discounts/redeem-code"],      "sections": [        {          "title": "Until when does a code work?",          "body": "Until the end of its last day in UTC, for every customer in every time zone. A code whose last day is 31 May works until 23:59:59 UTC on 31 May.",          "sources": ["checkout/discounts/redeem-code"]        },        {          "title": "Why was my code refused?",          "body": "The shop names the reason with a code.",          "table": {            "columns": ["Code", "Reason"],            "rows": [              ["E2002", "The code has expired."],              ["E2003", "The cart is below the code's minimum order value."],              ["E2004", "The order already has a code. Only one code per order."]            ]          },          "sources": ["checkout/discounts/redeem-code"]        }      ]    }  ]}
  • visibility: "public" keeps source paths and internal details out of the site and lists only active features. Use "internal" for a site your team reviews.
  • catalog: true adds a page with every feature the records describe, so nothing is missing just because no article covers it.
  • topics sort features by id prefix: everything under checkout/ lands in "Cart and checkout".
  • Each article section names its sources, the records it is based on. The text is yours; the check later ties it to those records.

If you prefer to start from a draft, leave articles empty at first: npx facet docs site compose --config docs/site.json then prints the configuration with one article per topic, built from the record summaries. Once articles has content, compose refuses, so it never overwrites your writing.

Step 2Check the plan and see what the records cannot answer yet

sh
  • npx facet docs site plan --config docs/site.json
Terminal output of npx facet docs site plan: JSON with one cluster, topic checkout with the feature checkout/discounts/redeem-code; gaps for that record: prerequisite_knowledge, not_for, discoverability, common_pitfalls, success_signal; no unassigned features.Terminal output of npx facet docs site plan: JSON with one cluster, topic checkout with the feature checkout/discounts/redeem-code; gaps for that record: prerequisite_knowledge, not_for, discoverability, common_pitfalls, success_signal; no unassigned features.
The plan sorts every feature into a topic and lists the questions its record leaves open.

plan validates the configuration and exits with an error if an article cites a record that does not exist, or a public article cites one that is not active. gaps lists KnowledgeKnowledge is the part of a record with five fixed questions about using the feature, such as prerequisites, limits and common mistakes. The owner answers them, and FACET generates help, FAQ and onboarding text from the answers.In the glossary questions the record's owner has not answered yet, such as common_pitfalls. The site never fills them with invented text; answer them in the record if readers need them.

Step 3Build the site and confirm it matches its sources

Keep the generated site and its lock file out of Git. The lock holds the digests the check compares against and is never published:

sh
  • printf 'docs-site/\ndocs-site.lock.json\n' >> .gitignore

Build and check:

sh
  • npx facet docs site build --config docs/site.json --output docs-site
  • npx facet docs site check --config docs/site.json --output docs-site
Terminal output: npx facet docs site build prints Documentation build: docs-site, then npx facet docs site check prints Documentation check: docs-site.Terminal output: npx facet docs site build prints Documentation build: docs-site, then npx facet docs site check prints Documentation check: docs-site.
Built and checked: the output matches records, code and configuration.

docs-site/ holds plain HTML, CSS and JavaScript with a local search, and needs no application server. Preview it locally with any static file server, for example:

sh
  • python3 -m http.server 8000 -d docs-site

Open http://localhost:8000/article-discount-codes.html:

The built help page Discount codes: breadcrumb Documentation / Cart and checkout, the section Until when does a code work? with the UTC answer, and Why was my code refused? with a table of the codes E2002, E2003 and E2004 and their reasons; each section has a collapsed Sources link.The built help page Discount codes: breadcrumb Documentation / Cart and checkout, the section Until when does a code work? with the UTC answer, and Why was my code refused? with a table of the codes E2002, E2003 and E2004 and their reasons; each section has a collapsed Sources link.
The article as readers see it, with its sources one click away.

Step 4Change the code and watch the check refuse the old site

Marketing extends the code KETTLE15 by a month. A developer changes one line in src/checkout/discount.ts, the file that carries the anchor of the discount-code record:

ts
  { code: "KETTLE15", kind: "percent", value: 15, expiresOn: "2026-12-31", minSubtotal: 5000 },

The article does not mention KETTLE15. Run the check anyway:

sh
  • npx facet docs site check --config docs/site.json --output docs-site
Terminal output of npx facet docs site check: documentation stale: record or anchor inventory changed; the command exits with status 1.Terminal output of npx facet docs site check: documentation stale: record or anchor inventory changed; the command exits with status 1.
The code behind the article changed since the build.

The check does not guess whether the change matters for the text. It says that something the site is based on changed, and exits with status 1. Someone reads the article again; here it still holds, because it never named that code. Remove the old preview and build again:

sh
  • rm -r docs-site docs-site.lock.json
  • npx facet docs site build --config docs/site.json --output docs-site
  • npx facet docs site check --config docs/site.json --output docs-site

The check prints Documentation check: docs-site again. Publish only the docs-site/ folder.

Step 5If the check says something else

  • documentation stale: record or anchor inventory changed: a record or a file with an @facet: anchor changed since the build. Read the affected articles, update them if needed, then rebuild.
  • documentation stale: editorial configuration changed: docs/site.json changed since the build. Rebuild after review.
  • documentation modified: index.html (or another file): somebody edited the built output. Rebuild instead of editing generated files.
  • destination exists: …/docs-site (build to a new directory): build never overwrites. Remove the old preview first, or pass another --output.
  • lock destination exists: …/docs-site.lock.json: the lock of the old build is still there. Remove it together with the old folder.

For more on keeping help content in step with the product, read The help article says 14 days. The code says 30.

Sources