Templates & Variables

Often there are many pages of the same kind, differing only by a value — “Python news” and “Go news”, say. Instead of creating a page for every variant, one sample page is enough. The value is substituted into it from the address.

The sample page

A sample is a folder whose name is written in square brackets, for example [tag]. One such folder serves any number of addresses: news/python, news/go, news/rust — all of them open the same page, but with different values inside. No new folder is needed for each variant.

  • A static page always beats the sample. If a separate news/press-releases folder exists, that is exactly what opens at this address, and the sample keeps serving the other values.
  • An edit “at the sample’s address” changes the sample itself. When the agent saves a page at an address like news/python and no separate folder exists, the changes land in the shared sample — and that is right: a text fixed once immediately improves for every value.

Where values come from

  • From the address. In the link /p/news/python the value python lands in the variable by itself.
  • From the link. A value can be passed at the end of the address after a question mark, for example news/[tag]?tag=python — then the value is substituted right on navigation. This works on the sample page that declares the variable; on a regular page without variables such a tail is simply ignored.
  • From a choice on the page. When a variable has several possible values, it can be picked right on the open page.

When the value is missing

When a sample is opened without the needed value, the portal does not guess what to substitute. Instead, a Path variables box with a choice list appears at the top of the page. Beside it the Resolved path is visible — the address that will result — and the Apply button opens the page at that address. No wrong choice is possible: the portal first shows where it leads.

Where the values go

The variable’s value is substituted into every text field of the page: the page title, its description, block headings, button labels, redirect addresses and the texts themselves. That is why a sample page looks like a normal page, not like a template with holes in it.

When a template is faulty

There are two cases. When a text mentions a variable that does not exist, an empty spot stays in its place — the page opens, just without that value. When the template itself is broken — a missing closing element in a substitution, for example — the structure check warns the agent, and it fixes the page. The reader never sees that message. Details are in the Page Validation section.

Next: who can see a page — in the Page Access section; how the public site works — in Public Site; how a page is laid out on disk — in Document Format.

← Back to the documentation index