# Domains

URL: /code/file-conventions/domains · Id: `page:code/file-conventions/domains`

> A file in domains/ is one Domain record, its role, what it hosts, its redirects and email at the domain.

A file in `domains/` is one [Domain](/business/nouns/domain): its role, what it hosts, its redirects and email at the domain. It implements the domains of the [site product](/products/site).

```text
domains/
├── leaseline.com.mdx      primary: the Site, the App and mail
└── leaseline.app.mdx      redirects to leaseline.com
```

## Reference
The file name is the hostname, and the file is frontmatter only. Buying and connecting are [Verbs](/business/nouns/verb), `Domain.register` and `Domain.connect`, never files.

Registrar status and certificate state are observed and never written.

| Key | Type | Holds |
| --- | --- | --- |
| `role` | `primary \| redirect \| mail` | What the Domain is for |
| `hosts` | path | The [Site](/business/nouns/site) or [App](/business/nouns/app) it serves |
| `redirects` | map | Host or path to target |
| `email` | map | `mailboxes` at the domain, and where mail forwards |

## Examples
### Minimal
```mdx title="domains/leaseline.com.mdx"
---
role: primary
hosts: sites/www
---
```

### Leaseline
```mdx title="domains/leaseline.com.mdx"
---
role: primary
hosts: sites/www
redirects: { www.leaseline.com: leaseline.com }
email: { mailboxes: [hello, support] }
---
```

## What it builds
The [SiteBuilder](/code/builders/site) compiles the file.

- the `Domain` record, connected with `Domain.connect` or bought with `Domain.register`
- DNS records for the Site, the App and mail, set with `DNSRecord.set`
- a certificate, renewed before it expires
- a [Mailbox](/business/nouns/mailbox) per address, authenticated with `Domain.authenticate`
- the [Events](/business/nouns/event) `Domain.connected` and `Domain.authenticated`

## Routing
The `hosts` path serves at the root of the hostname. The API serves at `/api` and the App at `/app` on the primary Domain.

## Good to know
- The founder's form of this file is the guide [connect my domain](/products/site/domains/connect-my-domain).