Site Variables

Site Variables

Site variable are global variables that are defined within your projects configuration and accessed using the site helper. These are useful for defining environment specific site variables such as google analytics code.

Defining site variables

Site variables are defined in your project configuration, within the site namespace.

For example if you're using PHP configuration files:

    return [
        'site' => [
            'title' => '',
            'url' => 'http://localhost:3000',
            'description' => 'Tapestry static site generator.',
            // ...

Or if using YAML configuration files:

    title: ''
    url: 'http://localhost:3000'
    description: 'Tapestry static site generator.'

Accessing site variables

Site variables are available from any phtml project file via the site helper; for example if I wanted to output the site title defined above I could do <?= $this->site('title') ?>.