# site

Source: https://zotonic.com/docs/1768/site

URI: https://zotonic.com/id/1768

Language: en



Retrieve information that is stored in the [site configuration](/id/doc_developerguide_configuration_site_configuration#ref-site-configuration). If you want to query values from the config table instead, you should use <a href="/id/doc_model_model_config" class="doc-reference doc-reference-model"><code>model#config</code></a>.

::: {.note title="Note"}
In general the site configurarion is only accessible via the `m.site` template model for users with administrator rights. Exceptions are keys starting with `public` or `{{ m.site.title }}`, hostname configurations and the *paglen*.
:::

Fetch a site configuration key
------------------------------

Example, fetching the site configuration key "hostname":

```django
{{ m.site.hostname }}
```

Fetching all configurations
---------------------------

It is easy to loop over all site configurations:

```django
{% for key, value in m.site %}
  {{ key }} -- {{ value }} <br>
{% endfor %}
```

Overriding config values
------------------------

Zotonic has two places where a site's configuration is kept. One is in the site's config files, the other in the config table. The config table (accessible through <a href="/id/doc_model_model_config" class="doc-reference doc-reference-model"><code>model#config</code></a>) overrules any module settings from the config file, for rows where the module key of the config value is set to site.

Within the site configuration, you can override module-specific configuration: Module configurations are defined with a property key equal to the module name, with a property list as value. For example:

```erlang
{mod_foo, [ {hostname, "localhost"} ]}
```

will put the default "hostname" setting of the imaginary `mod_foo` module to `localhost`.

Default config values
---------------------

Sites have the following default config settings:

| Property                  | Description                                                                      | Example value                                            |
| ------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------- |
| site                      | The name of the site, an atom.                                                   | `wwwzotonic.`                                            |
| environment               | Set the DTAP status of the site. Can be one of production, development, test, acceptance, education or backup. Default: production | `development`                                            |
| hostname                  | The hostname of the site                                                         | `example.com`                                            |
| title                     | The title of the site.                                                           | `"My Awesome Blog"`                                      |
| subtitle                  | The subtitle of the site.                                                        | `"Where content lives."`                                 |
| ui\_theme                 | The fixed theme for the user interface. `light`, `dark` or `auto`.               | `light`                                                  |
| pagelen                   | The default page length for searches and pagers.                                 | `20`                                                     |
| email\_from               | The email address configured as the From for outgoing emails.                    | [\`noreply@example.com](mailto:%60noreply@example.com)\` |
| protocol                  | The main protocol of the site. Used to construct urls. Default "http".           | `"https"`                                                |
| document\_domain          | The document domain used for cross domain iframe javascripts. Default is the same as the cookie\_domain. | `www.example.com`                                        |
| cookie\_domain            | The domain to use on cookies. This defaults to undefined, which will equal the domain of the current request. | `.example.com`                                           |
| session\_expire\_inactive | User inactivity timeout after seeing that the user has not been active. Default: 14400 (4 hours) | `3600 (1 hour)`                                          |
| autologon\_expire         | Auto logon cookie timeout setting. Default: 15552000 (3 months)                  | `31536000 (365 days)`                                    |
| hsts                      | Indicate if the site should use Strict Transport Security. When set, the browser will no longer use insecure http to access the site. Warning: Be sure your site is accessible via https before enabeling this feature. Default: false | `true`                                                   |
| hsts\_maxage              | The time, in seconds which browsers are allowed to remember the HSTS setting of the site. Default: 17280000 (200 days) |                                                          |
| hsts\_include\_subdomains | When set, the browser also does not use http for subdomains. Default: false      |                                                          |
| hsts\_preload             | When set, the site's HSTS setting will be stored by the browser vender. This means that browsers only use https. Use with care, because it is hard to revert wrong settings. Default: false |                                                          |

Available Model API Paths
-------------------------

| Method | Path pattern             | Description                                                                      |
| ------ | ------------------------ | -------------------------------------------------------------------------------- |
| `get`  | `/site/...`              | Return the current site name (atom) from the request context.                    |
| `get`  | `/environment/...`       | Return the resolved DTAP environment (`development`, `test`, `acceptance`, `production`, `education`, or `backup`). |
| `get`  | `/hostname/...`          | Return the configured hostname for the current site/request.                     |
| `get`  | `/hostname_port/...`     | Return hostname including configured HTTP port.                                  |
| `get`  | `/hostname_ssl_port/...` | Return hostname including configured HTTPS port.                                 |
| `get`  | `/hostalias/...`         | Return the configured `hostalias` site setting.                                  |
| `get`  | `/protocol/...`          | Return the site protocol used for URL construction (typically `http` or `https`). |
| `get`  | `/is_ssl/...`            | Return whether the site is currently considered SSL-enabled.                     |
| `get`  | `/title/...`             | Return the configured site title as binary text.                                 |
| `get`  | `/subtitle/...`          | Return the configured site subtitle as binary text (empty binary when unset).    |
| `get`  | `/ui_theme/...`          | Return the configured fixed UI theme (`light`, `dark`, `auto` or `user`) ('light' when unset). |
| `get`  | `/email_from/...`        | Return the effective sender address used for outgoing email.                     |
| `get`  | `/pagelen/...`           | Return default search page length (configured value or fallback default).        |
| `get`  | `/language/...`          | Return the current request language.                                             |
| `get`  | `/default_language/...`  | Return the site default language.                                                |
| `get`  | `/security/...`          | Return generated `security.txt` data (`contact`, optional `policy`/`hiring`, and `expires`). |
| `get`  | `/+key/...`              | Return site config value for `+key` when the key is public or caller is admin; otherwise `undefined`. |
| `get`  | `/`                      | Return all site configuration key/value pairs for admins, otherwise an empty list. No further lookups. |

`/+name` marks a variable path segment. A trailing `/...` means extra path segments are accepted for further lookups.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1768?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1768?language=en>)
