Lapis Docs

Building a site

Global settings

Global settings are the values that are the same on every page: the site's name, the menu, a phone number, an accent colour. You declare them in lapis.config.php, and admins edit them in the toolbar, under Settings.

Declaring them

Each setting is a field with a label, and the field's type decides how it is edited:

<?php // lapis.config.php
use Lapis\LapisConfig;
use Lapis\Settings\Fields\{Color, Image, Menu, Rows, Select, Text, Toggle, Url};

return new LapisConfig(
    locale: 'en',
    settings: [
        'site_name' => new Text('Site name', default: 'Lapis'),
        'menu' => new Menu('Main menu', default: [['label' => 'Home', 'url' => '/']]),
        'accent' => new Color('Accent color', default: '#c2410c'),
        'og_image' => new Image('Sharing image'),
        'theme' => new Select('Theme', ['light' => 'Light', 'dark' => 'Dark']),
        'newsletter' => new Toggle('Newsletter box', default: true),
        'social' => new Rows('Social links', fields: ['label' => new Text('Name'), 'url' => new Url('URL')]),
        'phone' => new Text('Phone', group: 'Contact details'),
    ],
    pageTypes: ['page' => 'Page', 'post' => 'Blog post'],
);

These field types are available in Lapis\Settings\Fields:

Field Value
Text, Textarea text
Email, Url an e-mail address, a safe address
Color a colour
Image an image from the media library
Time "HH:MM"
Toggle true or false
Select one of its options
Rows repeatable rows of sub fields, each of its own type
Menu a list of menu items

The group: argument puts a setting into a group of the Settings panel. Plugins use the same field types to describe how their blocks are edited, see Plugins.

In templates

Every template has the settings in $site:

<title>{{ $site->site_name }}</title>
<a :foreach="$site->get('social', []) as $link" :href="$link['url']">{{ $link['label'] }}</a>

$site->get() takes a default for a setting that is not filled in. In PHP code, use Lapis\setting('phone'). A Menu setting is what $cms->menu() falls back to while no page is marked "Show in the menu".

Name clashes

Settings fields, data table columns and form fields share some class names, such as Text and Email, in different namespaces. In a file that needs two of them, give one an alias:

use Lapis\Data\Columns\Text as TextColumn;

All options in lapis.config.php

Every argument of LapisConfig is optional and has a default:

Option Default What it sets
locale 'en' Language of <html lang>, og:locale and the editor (Translations)
settings [] Global settings shown in the Settings panel
pageTypes ['page' => 'Page'] Page types offered when creating a page (Routing)
pageCache null Full page cache for guests: null enables it in production only
sessionDays 14 Session lifetime in days for signed-in editors
maxUploadMb 16 Maximum upload size in megabytes (Images)
uploadExtensions ['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif', 'svg', 'pdf'] Allowed file extensions for uploads
imageSizes [] Named ImageSize definitions for <x-block type="image"> (Images)
imageMaxWidth 2000 Maximum width in pixels for images without a size
uploadMaxDimension 6000 Scales larger originals down on upload (0 disables it)
plugins [] Switch installed plugins off by name (['opening-hours' => false], Plugins)
backupKeep 14 Number of automatic backups kept (Deploying)
auditLogDays 365 Days audit log entries are kept (The editor and users)
schema new SchemaOrg() Home page JSON-LD type and property mapping (SEO)
articleTypes ['post'] Page types emitted as BlogPosting and og:type article (SEO)
robots [] Extra lines for /robots.txt in production (SEO)
ogImage new OgImageStyle() Automatic sharing image colours, or false to disable (SEO)
indexNow true Ping search engines on publish in production (SEO)
captcha null Captcha provider for forms (Forms)