# The addsite command

Source: https://zotonic.com/docs/2085/the-addsite-command

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

Language: en



<div>
            
  <div class="section">

<p>Adding a site to Zotonic is done through the <a class="reference internal" href="/id/doc_reference_cli_index#ref-cli"><span class="std std-ref">zotonic</span></a> shell command. It syntax is like this:</p>
<div class="highlight-erlang notranslate"><div class="highlight"><pre><span></span><span class="n">zotonic</span> <span class="n">addsite</span> <span class="p">[</span><span class="n">options</span><span class="p">]</span> <span class="o">&lt;</span><span class="n">site_name</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>This command creates a new site with [site_name] as the site’s
name. This new site will be based on a so-called <cite>skeleton
site</cite>. Currently there are four skeletons: ‘blog’, ‘empty’
and ‘nodb’. ‘blog’ is the default.</p>
<p>The addsite command is highly configurable and takes the following options:</p>

<p><div class="table-wrapper"><table class="docutils option-list">
<col class="option" />
<col class="description" />
<tbody valign="top">
<tr><td class="option-group">
<kbd><span class="option">-s <var>&lt;skel&gt;</var></span></kbd></td>
<td>Skeleton site (one of ‘blog’, ‘empty’, ‘nodb’; default: blog)</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-H <var>&lt;host&gt;</var></span></kbd></td>
<td>Site’s hostname (default: &lt;site_name&gt;.test)</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-L</span></kbd></td>
<td>Create the site in the current directory and symlink it into the zotonic user directory</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-g <var>&lt;remote&gt;</var></span></kbd></td>
<td>Create a git repository in the site and push it to the given remote</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-h <var>&lt;host&gt;</var></span></kbd></td>
<td>Database host (default: localhost)</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-p <var>&lt;port&gt;</var></span></kbd></td>
<td>Database port (default: 5432)</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-u <var>&lt;user&gt;</var></span></kbd></td>
<td>Database user (default: zotonic)</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-P <var>&lt;pass&gt;</var></span></kbd></td>
<td>Database password (default: zotonic)</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-d <var>&lt;name&gt;</var></span></kbd></td>
<td>Database name (default: zotonic)</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-n <var>&lt;schema&gt;</var></span></kbd></td>
<td>Database schema (default: &lt;site_name&gt;)</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-a <var>&lt;pass&gt;</var></span></kbd></td>
<td>Admin password (default: admin)</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-A <var>&lt;app&gt;</var></span></kbd></td>
<td>If true, initializes a site app and a root supervisor when the site starts (default: false)</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-U <var>&lt;umbrella&gt;</var></span></kbd></td>
<td>If true, the site dir becomes a multi-app structure (default: false)</td></tr>
</tbody>
</table></div>
</p>
<div class="section">
<h2>Adding a site</h2>
<p>When adding a site, the site will be created in the Zotonic user
directory. When <code class="docutils literal notranslate"><span class="pre">-L</span></code> is used, the site will be created in the
current directory (from which the <code class="docutils literal notranslate"><span class="pre">addsite</span></code> command is ran), and a
symlink into the Zotonic user directory will be made.</p>
<p>Before adding the site, the command will print out an
overview of what it will do before continuing.</p>
<p>For instance, consider the following addsite command:</p>
<div class="highlight-erlang notranslate"><div class="highlight"><pre><span></span><span class="n">zotonic</span> <span class="n">addsite</span> <span class="o">-</span><span class="n">s</span> <span class="n">blog</span> <span class="n">myfirstblog</span>
</pre></div>
</div>
<p>Will print out the following:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>************
Warning!
************
Site: 'myfirstblog.test' cannot be reached.
Command 'host myfirstblog.test' must resolve to an IP address,
otherwise you won't be able to reach it after installing the site.
You can fix that by adding the following line to /etc/hosts:

127.0.0.1         myfirstblog.test


==== Add site ====

Site name: myfirstblog
Site URL: http://myfirstblog.test:8000/

Skeleton site: blog
Site directory: /home/user/zotonic/apps_user/myfirstblog
Admin password: admin

Database host: 127.0.0.1
Database port: 5432
Database user: zotonic
Database password: zotonic
Database name: zotonic
Database schema: myfirstblog

>>> Hit return to proceed...
</pre></div>
</div>
<p>First, it will warn you that the hostname that this site (initially)
will have, is not yet resolvable. Add the hostname to your local hosts
file to be able to see the site when it has finished installing.</p>
<p>After this warning, the <cite>addsite</cite> command will print out an overview
of what it will do. It will show the site name, the URL the site will
be reachable on, in which directory the site will be installed, et
cetera. An overview of the database credentials and the admin password
will also be printed. After hitting return, the site will be created
and built for the first time. This will take a few moments, after
which you will be able to visit the site’s URL in your browser.</p>
</div>
<div class="section">
<h2>Default values to <cite>zotonic addsite</cite></h2>
<p>The “addsite” subcommand checks a file called
<code class="docutils literal notranslate"><span class="pre">$HOME/.zotonic-defaults</span></code> for the default values to these
options. This file is a file in bash-syntax which can define the
following variables: <code class="docutils literal notranslate"><span class="pre">SKEL</span></code>, <code class="docutils literal notranslate"><span class="pre">DBHOST</span></code>, <code class="docutils literal notranslate"><span class="pre">DBPORT</span></code>, <code class="docutils literal notranslate"><span class="pre">DBUSER</span></code>,
<code class="docutils literal notranslate"><span class="pre">DBPASSWORD</span></code>, <code class="docutils literal notranslate"><span class="pre">DBDATABASE</span></code>, <code class="docutils literal notranslate"><span class="pre">DBSCHEMA</span></code>, <code class="docutils literal notranslate"><span class="pre">ADMINPASSWORD</span></code>,
<code class="docutils literal notranslate"><span class="pre">SITEHOSTNAME</span></code>, <code class="docutils literal notranslate"><span class="pre">DO_LINK</span></code>, <code class="docutils literal notranslate"><span class="pre">TARGETDIR</span></code>.</p>
<p>For instance, if you want all new Zotonic sites to be created in
/var/www and have hostnames like <cite>www.mysite.intra</cite>,
<cite>www.anothersite.intra</cite>, add the following to your
<code class="docutils literal notranslate"><span class="pre">$HOME/.zotonic-defaults</span></code> file:</p>
<div class="highlight-erlang notranslate"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="nv">SITEHOSTNAME</span><span class="o">=</span><span class="s">"www.%%SITE%%.intra"</span>
<span class="n">export</span> <span class="nv">TARGETDIR</span><span class="o">=/</span><span class="n">var</span><span class="o">/</span><span class="n">www</span>
</pre></div>
</div>
</div>
<div class="section">
<h2>Available skeleton sites</h2>
<p>Zotonic comes with four different skeletons to base your site on.</p>
<dl class="docutils">
<dt><code class="docutils literal notranslate"><span class="pre">blog</span></code></dt>
<dd>As a full example of a Zotonic website, it installs a front page
with a listing of recent articles. As default example data, three
example articles and a couple of images are also installed.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">empty</span></code></dt>
<dd>An empty skeleton. No templates or dispatch rules whatsoever are
created. You can use this skeleton to create a new site based on
your own base templates, a custom CSS framework, etc.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">nodb</span></code></dt>
<dd>Like the <cite>empty</cite> template, but this skeleton does not require a
database connection. As such, the admin and content management
interface is disabled, as those modules all require a database
connection.</dd>
</dl>
</div>
</div>


           </div>

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2085?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/2085?language=en>)
