---
title: Sitemap
project: Total.js V4
version: 0.0.99
section: guides
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v4/0-0-99/guides/sitemap/
updated: 2026-11-16T15:41:10.817Z
---

# Sitemap

> Describe the pages of a website in the sitemap file and use it for navigation and breadcrumbs.

The file `sitemap` in the root of the application describes the pages of a website. Each line is `id : title --> url --> parent`:

```text
// sitemap
homepage : Homepage            --> /
products : Products            --> /products/          --> homepage
detail   : {0}                 --> /products/{0}/      --> products
contact  : @(Contact)          --> /contact/           --> homepage
```

Lines that start with `#` or `// ` are comments. `@(...)` around a title or URL translates it with the [localization](../localization/) resources. `{0}` is a placeholder that you fill later, and a URL that ends with `*` is a wildcard.

A route can use the ID instead of the URL. Without an action, the route renders the view with the name of the ID (`index` for `/`):

```js
exports.install = function() {
	ROUTE('#homepage');
	ROUTE('#products', 'products/list');
	ROUTE('GET #detail', detail);
};

function detail(id) {
	this.sitemap();
	this.sitemap_change('detail', 'name', 'Product ' + id);
	this.view('products/detail');
}
```

`#id` also works in `WEBSOCKET()`, `MERGE()`, `MAP()` and `LOCALIZE()`. A route with an unknown ID throws an error.

For an ID route with a view name or no action, the framework loads the breadcrumb itself; in your own action call `this.sitemap()`. It also sets the page title to the name of the current item. Views read the breadcrumb as `sitemap`:

```html
<ol class="breadcrumb">
@{foreach m in sitemap}
	<li><a href="@{m.url}">@{m.name}</a></li>
@{end}
</ol>

<a href="@{sitemap_url('detail', model.id)}">@{sitemap_name('products')}</a>
```

`SITEMAP(id)` returns the breadcrumb outside a controller, and `F.sitemap_navigation(parent)` the items with one parent, for menus.
