<!-- page:59314 -->
# Internals

Everything in Wikilayer rests on the node tree below: every block has a stable address, links find their way back, and a page still reads as one document. [MCP](page:4409) is how agents reach the same tree.

<!-- block:37127 -->
## Nodes

Wikilayer stores writing in one tree. Each node has a title and Markdown body; a page holds the blocks that make up its sections and sits under the wiki or under another page, and that page tree is the wiki's navigation. The browser renders the page for people, and [MCP](page:4409) exposes the same nodes to agents.

<!-- block:39329 -->
### Heading levels come from the tree

A block directly below a page renders as h2; a block below it renders as h3. A heading typed into a Markdown body has no node of its own, so the tools reject it. Each section is its own block, so it shows up in the page's contents and can be linked to directly.

<!-- block:39330 -->
## What nodes provide

Each node has a stable ID, a parent, and its own change history.

<!-- block:39331 -->
### Links survive renames

A `block:N` reference uses the node's stable ID. Renaming, rewriting, or moving that node leaves the link intact.

<!-- block:39332 -->
### Backlinks are automatic

Because links target node IDs, Wikilayer can list the pages that point to a node. The list appears on the page and in its stitched Markdown document.

<!-- block:39333 -->
### A move carries the subtree

`move_node` changes a node's parent. Its descendants move with it, and their heading levels follow the new depth. A `sort_key` positions the node among siblings without editing their bodies. `migrate` can move a subtree to another wiki when no links would cross the wiki boundary.

<!-- block:39334 -->
### History belongs to each node

Each node keeps its own versions and `updated_at`. Changing one block adds a history entry for that block without changing its neighbours.

<!-- block:39335 -->
### The outline avoids full-wiki reads

`get_outline` maps a wiki through titles, IDs, and token counts without sending every body.

<!-- block:39326 -->
### Links connect branches

The tree gives each node one parent. Short refs link related nodes elsewhere in the wiki, and backlinks show the reverse connections without duplicating the content.

<!-- block:39336 -->
## Reading and export

<!-- block:39337 -->
### A page reads as one document

The browser renders a page with its sections in order. `get_page_markdown` returns the same page to an agent, with a comment before each node carrying its ID. Public wikis also serve the assembled document as a [Markdown view](page:60823).

<!-- block:39338 -->
### Content is portable

A [wiki export](page:56240) contains its Markdown, files, and structure, so the content can be kept outside Wikilayer.

---

## Links here

- [Wikilayer manual](/smee-again/wikilayer-howto/en)
- [Markdown](page:4402)
- [Markdown view](page:60823)

---

[All pages](https://wikilayer.org/smee-again/wikilayer-howto/en/index.md)
