> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailglyph.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> Create reusable email templates for your campaigns, workflows and transactional emails

Templates are stored in the MailGlyph dashboard and can be used in campaigns, workflows and transactional emails.

## Designing templates

Templates can be created using the built-in editor or by uploading your own HTML.

### Personalization

You can use contact data to personalize your templates by using the handlebars syntax `{{ key }}`, where `key` is the contact data key.

#### Always Available Variables

These variables are always available in your templates, regardless of custom contact data:

| Variable | Description |
| - | - |
| `{{id}}` | The contact's unique identifier |
| `{{email}}` | The contact's email address |
| `{{unsubscribeUrl}}` | URL to the unsubscribe page |
| `{{subscribeUrl}}` | URL to the subscribe/resubscribe page |
| `{{manageUrl}}` | URL to the preferences management page |

#### Fallback Values

You can provide fallback values for variables that might not be set:

```
Hello {{firstName ?? 'there'}}!
```

If `firstName` is not set, this will render as "Hello there!"

#### Special Fields

The following fields are reserved by MailGlyph but can still be used.

| Variable | Description |
| - | - |
| `{{subscribed}}` | Contact's subscription status (true/false) |
| `{{locale}}` | Contact's preferred locale (e.g., 'en', 'fr', 'es') |

### Previewing templates

You can preview your templates by selecting a contact in the preview window. This will allow you to see how the template will look for that specific contact, with their data populated.

## Templates types

There are three types of templates in MailGlyph. Each type is treated at the same priority when sending emails, you should not pick one type over the other based on deliverability or performance.

| Type | Respects opt-out | MailGlyph unsubscribe footer | Description |
| - | :-: | :-: | - |
| Marketing | Yes | Yes | Automatically includes a MailGlyph-hosted unsubscribe footer. Will not be sent to contacts who are unsubscribed |
| Transactional | No | No | Does not include any way to unsubscribe. Will be sent to any contact, regardless of subscription state |
| Headless | Yes | No | Respects opt-out like marketing, but no MailGlyph footer is appended. You are responsible for adding an unsubscribe mechanism using `{{unsubscribeUrl}}` or `{{manageUrl}}` to link to Mailglyph's managed unsubscribe page |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.