PureWiki handles user requests for content (the public wiki) using an efficient routing and rendering engine. This guide explains how the system translates a URL into a fully realized HTML page.

The Router (index.php)

Every request passes through index.php. It normalizes the requested URL and determines if the path points to /setup, a dashboard route, or a regular wiki page.

Rendering Pipeline:
Public requests are delegated to the frontend rendering system (purewiki/frontend/renderer.php).

Before a public page is rendered, the router handles these cases in order:

The Rendering Engine

The renderPage() function is the core of PureWiki generation. It handles:

  1. Data Extraction: Parses the page.json to retrieve metadata and blocks.
  2. Content Parsing: Blocks are converted into semantic HTML via purewiki/frontend/parser.php.
  3. Theme Injection: The aggregated data and HTML content are passed to the active theme template. The color overrides of the Theme Colors setting are added to the head.
  4. Placeholder Replacement: Replaces specialized placeholders (e.g., {{ content }}, {{ assets_head }}) within the theme's output.

The Caching Mechanism (/cache)

To deliver lightning-fast response times, PureWiki uses a robust static HTML caching system.

Cache:
For unauthenticated users, static HTML files are served, bypassing PHP processing and JSON parsing.
Note:
Caching is explicitly disabled for authenticated users to always show the most up-to-date content during active editing.

Sitemap (sitemap.xml)

PureWiki dynamically generates a sitemap.xml to aid search engine indexing. It is served from the wiki root and follows the sitemaps.org standard.

Generation Logic:
The sitemap traverses the page tree (getCachedPagesTree()) and automatically excludes private pages. Priority is dynamically calculated based on page depth.

On-Demand Assets

Libraries are only loaded on pages that need them. While parsing, the blocks request Prism.js (code blocks), KaTeX (math) and Iconify (icons) through the AssetManager. Extensions can add their own files, see Extension Development.