Docs > Templating

Web templates are written in XHTML, with a handful of tags used to add "content editability".
Here's a simple example of a web template:
<html>
<head>
<title><page:name/></title>
<link rel="stylesheet" type="text/css" href="global/style.css" />
</head>
<body>
<div id="wrapper">
<img src="images/logo.gif" alt="Our logo"/>
<h1><content:string id="title"/></h1>
<content:text id="summary" schema="plain" height="120"/>
<content:text id="body" schema="styled" height="300"/>
</div>
<div id="sidebar">
<content:picture name="photo" width="120" height="200"/>
</div>
</body>
</html>
You can see that the template is more or less normal XHTML. You can put whatever markup you like in a template (as long as it follows the usual rules of XHTML), and it will be passed through to pages based on the template.

Editable text

A couple of interesting things to notice are the <content:text> tags. These are text placeholders. When this template is used to create a page, these areas will be editable by your users.

Similarly, the <content:picture> tag is used to create a picture box, that can be filled with an image when the page is edited.

You can find out more about these, and other tags, here.


Componentizing your code

You can create reusable blocks of code, and include them in a template using your account name as a tag prefix. Find out more here.


Scripting

You can embed server-side scripts in a web template, in order to access the PostCMS API to retrieve content and so on. Here's an example:
<js? 
var home = Page.get('index.html'); // get the home page
out.writeln(home.name);
?>
To just write out the value of a script variable, you can use this shorthand syntax:
<title><?js=page.name?></title>
In an attribute value, use curly brackets instead:
<?js var path = 'more.html'; ?>
<a href="{path}">Read more</a>
These scripts are evaluated when the page is generated, not when it is viewed on the live website.

Find out more about scripting here.

Can't find what you're looking for?

Let us know and we'll see if we can help.