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:
Similarly, the
You can find out more about these, and other tags, 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:
Find out more about scripting here.
<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.
<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>
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?To just write out the value of a script variable, you can use this shorthand syntax:
var home = Page.get('index.html'); // get the home page
out.writeln(home.name);
?>
<title><?js=page.name?></title>In an attribute value, use curly brackets instead:
<?js var path = 'more.html'; ?>These scripts are evaluated when the page is generated, not when it is viewed on the live website.
<a href="{path}">Read more</a>
Find out more about scripting here.



