Templates( live)


  • template is a special page that defines common items to display on pages in a category
  • templates are easy way to change the layout for pages in a category
  • the name of the special page defining the layout for a category is category:_template (examples below)


To create a template for a category you create a page called "_template" in that category. For the default category, the template page is called "_template". For example:


Pages that start with an underscore are not listed by other modules and hidden in most cases.

Defining layout

The purpose of a template is to define a layout of pages within a category. Here is a simple template that forces the height of the content box. Create a page called _template with this code, and then reload the start page of your site:

[[div style="min-height:600px"]]

Here is a more typical template, which adds a comments module below the page content:

+ Original content of the page below



[[module Comments]]

It is easy to image what it really does. When this markup is saved as some-category:_template, all pages from the some-category will be combined with the template during rendering. Content of the page will be substituted into the %%content%% tag. This way we can add headers, side bars, navigation elements, modules and comment boxes to the template and the viewed page will automatically have it.

When you try editing a page from the category, only the "inside content" is editable. Template is applied only when viewing the compiled page.

Splitting the content

Let us start with an example of a template:

[[div style="float:right; width: 200px; border: 1px solid #999; margin: 10px;"]]




This will be content of the side bar.


The main content.


This will go into the left cell of the table.


And this into the right cell.

There are two things described above: splitting content and default page content.

Splitting allows you to create sections in the page and manipulate them separately in the template. Sections are separated by a series (4 or more) "equals" characters and are referred to as %%content{X}%% in the template. You can access them in any order within the template.

Using this you can easily create advanced layouts (like multicolumn, multi-navigation etc.) and make editing and maintenance much easier.

Default content

Also in the template you can provide the default initial content for newly created pages. Such content is separated from the template by the '====' tag - the same as for splitting the content. To make it visually different you can make it longer — e.g. 10 characters. When a user wants to start a new page in the category, this content will be placed in the editor.

Also, when default content is defined for the template, there will be no option for selecting templates from the templates category (our previous templating mechanism).

Escaping the ==== tag

Since you might want to use the "====" tag in the content of a page and NOT as a splitter, there is a way to escape the splitter and prevent the default action. Surround the splitter with "@@" like this:


You can also escape the "====" tag by adding a space. This is the only way to escape it inside a code block. Note: if you copy/paste code that contains '====', make sure it does not still have a space at the end of the line, or it will not work!

Page variables within the _template

The template consists of wiki text mixed with variables specified as %%variable-name%%. You can use these variables:

Property Meaning
Page lifecycle
%%created_at%% Date page was created
%%created_by%% User who created page
%%created_by_unix%% "Unixified" name of user who created page — to be used for constructing URLs
%%created_by_linked%% Icon and link to user who created page
%%updated_at%% Date page was updated (edited, tagged, parented)
%%updated_by%% User who updated page
%%updated_by_unix%% "Unixified" name of user who updated page — to be used for constructing URLs
%%updated_by_linked%% Icon and link to user who updated page
%%commented_at%% Date of last comment
%%commented_by%% User who made last comment
%%commented_by_unix%% "Unixified" name of user who made last comment — to be used for constructing URLs
%%commented_by_linked%% Icon and link to user who made last comment
Page structure
%%name%% Page name without category
%%category%% Page category if any
%%fullname%% Page name with category if any
%%title%% Page title
%%title_linked%% Link to page showing title as text
%%parent_name%% Parent page name without category
%%parent_category%% Parent page category if any
%%parent_fullname%% Parent page name with category if any
%%parent_title%% Parent page title
%%parent_title_linked%% Link to Parent page showing title as text
%%link%% URL pointing to page
%%content%% Page content
%%content{n}%% Numbered content section
%%summary%% Summary of content
%%first_paragraph%% The first paragraph of the page
%%tags%% Page visible tags (not starting with underscore)
%%tags_linked%% Page visible tags linked to system:page-tags/tag/{tag}
%%tags_linked|link_prefix%% Page visible tags linked to link_prefix{tag}
%%_tags%% Page hidden tags (starting with underscore)
%%_tags_linked%% Page hidden tags linked to system:page-tags/tag/{tag}
%%_tags_linked|link_prefix%% Page hidden tags linked to link_prefix{tag}
%%form_data{name}%% Field value from page data form if any
%%form_raw{name}%% For select and pagepath fields, the internal value saved in the page form data. For other field types, empty.
%%form_label{name}%% The label of the field as defined in the data form if any
%%form_hint{name}%% The hint of the field as defined in the data form if any
Page reporting
%%children%% Number of child pages
%%comments%% Number of comments on page
%%size%% Number of characters in page
%%rating%% Page rating value
%%revisions%% Number of revisions to page
Current context
%%site_title%% Title of current site
%%site_name%% Wikidot Unix name for site
%%site_domain%% Active domain name of current site

Date formatting:

  • All _at fields are dates and allow a custom format via the |format specifier.

Most tokens from PHP's strftime are accepted. You may find the howto contributed by community useful.

An example of how these can be used in a blog could be (e.g. in blog:_template:

by %%created_by%% on %%created_at|%e %B %Y%%
rating: %%rating%%, tags: %%tags%%


Changing the template

When you edit the _template page for the given category, all pages from the category will be recompiled to include the changed template.

Hidden pages

Pages whose name starts with an underscore (like "_start", "_header", etc.) are 'hidden' pages and are not affected by the template.


This is the (old) Standard Template used - but better is always to use the LIVE template ( above)

How to use templates.

What are they?

These are pre - prepared pages, pro formas, or forms that you may wish your wikidot contributers to use. An excellent example can be found at http://siliconcity.wikidot.com/template:herocharacter.

Step one.

Preparing a Template

But before we do, go and have a look in Site Manager » Page templates
Note that it will inform you that you don't have any!


So best we make one.

Using the new page button on the side menu bar, create a new page called (for example):-


the "template" is the category reserved for templates.
"typeone" is the name you wish to give it.

Then type some text in it how you would like. You can always edit it later, so for example lets put in:-

  • Ingredients
  • Cooking time
  • method
  • serves

Save it.

Just for the hell of it, let create another template called "typetwo"
Again, in the New Page box on the side bar create a page named

Then enter some text, eg:-

  • Country of origin
  • Alloy type
  • Value

Now lets go back to Site Manager » Page templates

You will see two boxes.


The left one shows the Categories used in your site.
The right one lists the templates you have made.

If you click on the templates listed, you will see a preview underneath. (note i could only get it to preview one of them. I think there is a bug, but don't worry)

Now go back to your site
Create a new page in the New page box on the side bar.
Have a look in the edit box
you should see a new drop down box

Initial template: |~ no template (default)|

This should display the templates you have created. (note there is also a number of no template (default) listed. Again I think this is a bug.)

Click on the one you wish to use.

Job Done!!

Part two:

Assigning templates to Categories.

You might find it useful to use a particular template for a particular category.

category Template
breads bread template
meats meat template
Cakes Cake template

First lets create the templates as we did above.

eg :-

  • template:bread template
  • template:meat template

Then we create the categories, using the New Page box. More info here. It will be a good idea to have a "base" "start"page, or "Introduction" page to each category.

  • Breads:basebread
  • Meats:basemeat

Adding the create page box

Lets use "breads" as an example.

  • create template. Called. template:breads
  • create new page called breads:basebread

In the new breadbase page inset the following code

[[module NewPage category="breads"]]

Once you have saved that new page you should have a new "create page" box displayed


creating new pages within it, eg:-

  • newpage one
  • newpage two
  • newpage three

will do two things.

  1. create a new page and automatically put it in the "breads" category
  2. present the user with the template required for that category.

Step Three:

The Side Bar

Instead of having a base page with the Create new page module, we can place that module on the Side (nav:side) Bar.
In the default set up, using the New page module, will give you the opportunity to chose which Template you wish to use.

If we create a NEW Side bar, and assign that to say the Base Category, then we can use that to give the required template as the default option.

For example:
Have a look at at the side bar to your left. Right at the top it says "nav:side-en"
This is the actual page name of that particular side bar.
Now have a look : Here
Notice at the top, it says "nav:side-de." This is the German category side bar
Just to hammer it home, have a look here
This is the Spanish version of the side bar

Adding New page to it

In each of these Side bars we could add a Create Page module.
When we enter a page name in it, it will automatically assign that page to that particular category, and if we tell it to, we can make it apply a specific template.

eg: Inserting the following into the a side bar that has been assigned to the category "breads"

[[module NewPage category="breads" size="15" button="new page"]]

Will generate a new page, automatically put it in the "breads category, AND if a template has been assigned to that category, automatically provide you with that template.

EDIT: This does not work as explained.
Your explanation suggests that when one creates a "template:name-one" and a page "name-one:first" the template is automatically used without invoking it. This is not so. And the similar page names between the "template:X" and "X:demo-page" have no relations. Instead one needs to use

[[module NewPage category="ball" template="round-object"]]

Bookmark and Share

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License