# Template Variables Reference
Templates have access to a set of variables provided by FolderWeb and its plugins. This reference documents all available variables and their types.
## Base Template Variables
Available in `base.php`:
### `$content`
The fully rendered HTML content from the page or list template.
**Type:** String (HTML)
**Example:**
```php
= $content ?>
```
### `$pageTitle`
The page title for the `
` tag.
**Type:** String
**Default:** `"FolderWeb"`
**Example:**
```php
= htmlspecialchars($pageTitle ?? 'FolderWeb') ?>
```
**Source:**
1. Language-specific metadata `[lang] title`
2. Root metadata `title`
3. First heading in content
4. Folder name
### `$metaDescription`
SEO description for the `` tag.
**Type:** String
**Optional:** May be empty
**Example:**
```php
```
**Source:**
1. Metadata `search_description`
2. Metadata `summary`
3. Empty if not set
### `$socialImageUrl`
URL to cover image for social media meta tags.
**Type:** String (URL)
**Optional:** May be empty
**Example:**
```php
```
**Source:** First `cover.*` image found in content directory
### `$navigation`
Array of navigation menu items.
**Type:** Array of associative arrays
**Structure:**
```php
[
['url' => '/about/', 'title' => 'About'],
['url' => '/blog/', 'title' => 'Blog'],
['url' => '/contact/', 'title' => 'Contact'],
]
```
**Example:**
```php
```
**Source:** Pages with `menu = 1` in metadata, sorted by `menu_order`
### `$homeLabel`
Text for the home link.
**Type:** String
**Default:** `"Home"`
**Example:**
```php
= htmlspecialchars($homeLabel ?? 'Home') ?>
```
**Source:** Translation string `translations['home']` or fallback "Home"
### `$currentLang`
Current language code.
**Type:** String
**Default:** From `config.ini` `languages.default`
**Example:**
```php
```
**Values:** ISO 639-1 language codes (`en`, `no`, `de`, etc.)
### `$langPrefix`
URL prefix for the current language.
**Type:** String
**Default:** Empty string for default language
**Example:**
```php
Home
```
**Values:**
- `""` (empty) for default language
- `"/no"` for Norwegian
- `"/de"` for German
- etc.
### `$languageUrls`
URLs to switch between available languages.
**Type:** Associative array
**Structure:**
```php
[
'en' => '/page/',
'no' => '/no/side/',
'de' => '/de/seite/',
]
```
**Example:**
```php
1): ?>
```
### `$translations`
Translated UI strings for the current language.
**Type:** Associative array
**Structure:**
```php
[
'home' => 'Home',
'footer_handcoded' => 'Generated in',
'footer_page_time' => 'ms',
'months' => 'January,February,March,...',
]
```
**Example:**
```php
```
**Source:** Language files in `custom/languages/[lang].ini` or `app/default/languages/[lang].ini`
### `$pageCssUrl`
URL to page-specific CSS file.
**Type:** String (URL)
**Optional:** Only set if `styles.css` exists in content directory
**Example:**
```php
```
### `$pageCssHash`
MD5 hash of page-specific CSS for cache busting.
**Type:** String (MD5 hash)
**Optional:** Only set if `$pageCssUrl` exists
**Example:** See `$pageCssUrl` above
## Page Template Variables
Available in `page.php`:
### `$content`
The fully rendered HTML content from the page.
**Type:** String (HTML)
**Example:**
```php
= $content ?>
```
### `$metadata`
All metadata for the current page.
**Type:** Associative array
**Structure:**
```php
[
'title' => 'Page Title',
'summary' => 'Short description',
'date' => '2024-12-15',
'formatted_date' => '15. desember 2024',
'show_date' => true,
'author' => 'Jane Doe', // Custom fields
'tags' => 'web,design',
// ... all other metadata fields
]
```
**Example:**
```php
= htmlspecialchars($metadata['title']) ?>
```
## List Template Variables
Available in `list.php`, `list-grid.php`, `list-compact.php`, etc.:
### `$pageContent`
Optional intro content from the directory's own files.
**Type:** String (HTML)
**Optional:** May be empty
**Example:**
```php
= $pageContent ?>
```
**Source:** Content files in the list directory itself (not subdirectories)
### `$items`
Array of items to display in the list.
**Type:** Array of associative arrays
**Structure:**
```php
[
[
'url' => '/blog/my-post/',
'path' => '/content/blog/2024-12-15-my-post',
'title' => 'My Post',
'summary' => 'Short description',
'date' => '2024-12-15',
'formatted_date' => '15. desember 2024',
'cover_image' => '/blog/my-post/cover.jpg',
// All custom metadata fields...
'author' => 'Jane Doe',
'category' => 'Tutorial',
],
// ... more items
]
```
**Example:**
```php
```
## Debugging Variables
To see all available variables in a template:
```php
```
Or specific variables:
```php
```
**Remember to remove debug code** before deploying to production.
## What's Next?
- **[Internationalization](#)** — Use language-specific variables
- **[Creating Plugins](#)** — Add custom template variables
- **[Template Tutorial](#)** — See variables in action