site

Retrieve information that is stored in the site configuration. If you want to query values from the config table instead, you should use m_config.

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”:

{{ m.site.hostname }}

Fetching all configurations

It is easy to loop over all site configurations:

{% 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 m_config) 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:

{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:

PropertyDescriptionExample value
environmentSet the DTAP status of the site. Can be one of production, development, test, acceptance, education or backup. Default: productiondevelopment
hostnameThe hostname of the siteexample.com
titleThe title of the site.“My Awesome Blog”
protocolThe main protocol of the site. Used to construct urls. Default “http”.“https”
document_domainThe document domain used for cross domain iframe javascripts. Default is the same as the cookie_domain.www.example.com
cookie_domainThe domain to use on cookies. This defaults to undefined, which will equal the domain of the current request..example.com
session_expire_inactiveUser inactivity timeout after seeing that the user has not been active. Default: 14400 (4 hours)3600 (1 hour)
autologon_expireAuto logon cookie timeout setting. Default: 15552000 (3 months)31536000 (365 days)
siteThe name of the site, an atom.wwwzotonic.
hstsIndicate 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: falsetrue
hsts_maxageThe time, in seconds which browsers are allowed to remember the HSTS setting of the site. Default: 17280000 (200 days)
hsts_include_subdomainsWhen set, the browser also does not use http for subdomains. Default: false
hsts_preloadWhen 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

Edit on GitHub

config Models admin_config

Referred by

Template Best Practices and Pitfalls

This chapter lists some preferred solutions to common tasks and pitfalls you may encounter while developing with…

config

Zotonic has two places where a site’s configuration is kept: