Conditional content
wc-if includes or removes content at build time. Content that does not match never reaches the page HTML, the search index or the generated Markdown and llms.txt output, so there is nothing to hide with CSS and nothing for a crawler to find by accident.
Show content to agents or to people
The for attribute picks an audience:
for="agents"appears only in the generated Markdown that AI agents read. It is hidden on the web.for="humans"appears only on the web page, and is dropped from the agent Markdown.
Use for="agents" for context that helps a model but would clutter the page, such as exact identifiers, constraints and a reminder of the safe order of operations. Use for="humans" for interactive pieces that mean nothing in plain Markdown, such as a button, a tooltip or a video.
This page shows the effect. The next sentence exists only in the agent Markdown: open the Markdown version of this page to read it.
Agent Markdown is what .md URLs, llms-full.txt, Accept: text/markdown requests and the MCP server return. See Reading docs as an agent.
Replace a whole page for agents
To give agents a different page, not just a different block, add docs/<id>.agent.md next to docs/<id>.md. The .agent.md body replaces the page body in everything agents read: dist/<id>.md, llms-full.txt, and so the MCP servers and content negotiation. The web page and the site search index keep the normal page.
Use wc-if for="agents" when a page is mostly the same for both audiences and you need a few extra lines. Use an .agent.md file when the page depends on layout, tabs or interactive components that mean little in plain Markdown, and a tighter rewrite serves agents better.
An agent rendition follows these rules:
- The body is used as written. Variables such as
{{VAR}},wc-*components and includes aren't processed. - Its own frontmatter is dropped. The page's frontmatter handling still applies, including
agents.markdownFrontmatter. - A file over 1 MiB is ignored with a build warning.
- It isn't a page. It never appears in an automatic sidebar, doesn't count as an orphan page and isn't linted.
- For a locale, put it in
docs.<locale>/<id>.agent.md. A page that falls back to the default language uses the defaultdocs/<id>.agent.md. - In a versioned site, each version reads the file from its own branch. Changing only the
.agent.mdfile rebuilds that page.
docslit validate warns with agent-rendition-orphaned when an .agent.md file has no matching <id>.md.
Other conditions
You can combine conditions on one element. All of them must hold.
| Attribute | Condition |
|---|---|
version |
The build is for one of the listed versions (a comma-separated list), for versioned docs |
locale |
The page is in one of the listed locales. The default locale is en. See Internationalization |
attr |
The named variable from attributes is set and not empty, false or 0 |
equals |
With attr: the variable equals one of the listed values |
not-equals |
With attr: the variable equals none of the listed values |
not |
Invert the version, locale or attr condition |
for |
humans or agents |
By version
By variable
Define a variable in docslit.json, then branch on it. This is a clean way to build a self-hosted and a cloud edition from the same pages:
By locale
humans (web page only) or agents (agent Markdown only).docs.<locale>/. The default locale is en.docslit.json attributes or page frontmatter. Alone, it is true when the variable is set and not empty, false or 0.attr: comma-separated values that the variable must equal.attr: values that the variable must not equal.version, locale or attr condition.Rules
- Leave a blank line after the opening tag and before the closing tag when the content is block Markdown, such as a list or a code fence.
- Evaluation happens before the page is rendered, so content inside a
wc-ifcan use variables, includes and any other component. - Only matching content is searchable and visible to agents, so do not put anything in a non-matching branch that must stay secret. It never reaches the output of that build, but it is in your source.
Migrating from Mintlify or Fern
The importer converts the conditional components of both platforms:
| Platform | Source | DocsLit |
|---|---|---|
| Mintlify | <Visibility for="agents"> and for="humans" |
<wc-if for="agents"> and for="humans" |
| Fern | <llms-only> and <llms-ignore> |
<wc-if for="agents"> and for="humans" |
| Fern | <If versions={["v1"]}> |
<wc-if version="v1"> |
Content gated by login, roles or groups cannot exist on a static site, so the importer removes it and reports it. See the component mapping.
Next steps
- Branch on variables and precedence
- Learn how agents read your docs in Reading docs as an agent
- Show a version badge inline with version-specific content