Go to page content


Site configuration access.

Zotonic has two places where a site’s configuration is kept. One is in the site’s config file, the other in the config table. The config table overrules any module settings from the config file.

The site configuration is stored for each site in priv/sites/<sitename>/config. Its syntax is equal to an Erlang property list. Some properties can be repeated, for example the “hostalias” property.

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_emailer, [ {smtp_host, "localhost"} ]}

will put the default "smtp host" setting of the e-mail module to the localhost.

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 %}

{% endfor %}

Fetching all values of a repeating config

Some config keys have multiple values. To fetch all values of, for example, the “hostalias” key use:

{{ m.site.all.hostalias }}

This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.