Template Record Variables and Syntax
Table of Contents
- The {{domain}} variable
- The {{domain}} variable
- The @ shorthand
- The SRV case
- Priority is a separate field
- Have more questions?
DNS template records support two substitutions that are resolved when the template is applied to a domain: the {{domain}} variable and the @ shorthand. Both are replaced with the name of the domain the template is applied to.
For what templates are and how to apply them, see How DNS Templates Work and How to Use Templates.
The {{domain}} variable
The {{domain}} variable
{{domain}} is a value you type into a template record’s content field. DNSimple does not insert it for you. When you apply the template to a domain, {{domain}} is replaced with that domain’s name.
A template record with the content {{domain}} applied to example.com produces example.com. It can also appear inside a longer value, such as www.{{domain}}, which becomes www.example.com.
{{domain}} is the only variable available in templates you create. One-click services use the same substitution mechanism with a larger set of variables, because a service can collect settings from you when you apply it. Those variables do not work in your own templates.
The @ shorthand
@ in a record’s content is replaced with the domain name, but only under specific conditions.
Record types that support it
| Record type |
|---|
| A |
| AAAA |
| CNAME |
| MX |
| URL |
| NS |
| SRV |
@ is not substituted in any other record type. In a TXT record, for example, @ is left exactly as written.
When it is substituted
For the record types above, @ is replaced when either of the following is true:
- The content is exactly
@, with nothing else in the field - The content ends with
@., which applies to SRV records only
An @ anywhere else in the content is left alone. A CNAME with the content www.@ is not substituted, because the @ is neither the entire value nor a trailing @. on an SRV record.
Examples
Applied to example.com:
| Record type | Template content | Result |
|---|---|---|
| CNAME | @ |
example.com |
| MX | @ |
example.com |
| SRV | 100 443 @. |
100 443 example.com |
| TXT | @ |
@ (not substituted) |
| CNAME | www.@ |
www.@ (not substituted) |
The SRV case
The trailing @. rule exists for SRV records specifically. SRV content holds a weight, a port, and a target, so the target sits at the end of a longer string rather than filling the field on its own. Without this rule there would be no way to point an SRV target at the domain apex from inside a template.
See SRV records in templates for how the rest of an SRV record is split across the template fields.
Priority is a separate field
Priority is its own field on a template record. It is not part of the content string, and no substitution is applied to it. This matters most for SRV and MX records, where priority is part of the record but not part of the content you type.
Have more questions?
If you have any questions about template variables, just contact support, and we’ll be happy to help.