---
title: CMS compiler
project: Total.js V5
version: 0.0.20
section: guides
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v5/0-0-20/guides/cms/
updated: 2026-11-16T15:32:37.496Z
---

# CMS compiler

> Compile pages made with the Total.js CMS editor and render them with their widgets.

`F.TCMS` compiles pages made with the Total.js CMS editor. A page is HTML where every widget is an element with `data-cms="<widgetid>__<config>"`. `F.TCMS.compile(html, widgets)` prepares the page once, and `render()` makes the HTML for each request: it calls `render(opt, next)` of every widget and fills the navigation templates.

```js
var widgets = [{
	id: 'hello',
	css: '.hello { color: red; }',
	render: function(opt, next) {
		next('<b>Hello ' + opt.config.name + '</b>');
	}
}];

var page = F.TCMS.compile(html, widgets);
page.importcss();

var output = await page.render({
	url: '/about/',
	navigation: function(id) {
		return [{ url: '/', name: 'Home' }];
	}
});
```

A `<script type="text/navigation" id="main">` in the page is a Tangular template; its `value` is what `navigation(id)` returns, where `id` is the `id` attribute (a navigation with only a `name` attribute gets a hash of the name). A `<script type="text/breadcrumb">` gets `opt.breadcrumb`. Elements with the class `CMS_trash` or `CMS_editor` are removed. The CSS and JS of the widgets are minified and joined into `page.css` and `page.js`.
