Skip to content

Aurora 1.5 is out!

What's new →
Docs menu

Building a site

Layouts and the website

The views that draw whole pages, and everything Aurora serves.

A layout is a Blade view that draws a whole page: <head>, header, the blocks and the footer. Aurora ships four: standard (the default: header, menu and footer), landing (the header floating over the first block), minimal (the logo alone, for campaigns) and blank (the page alone), published to resources/views/vendor/aurora/layouts on install so the site can make them its own. This website adds two of its own: the landing page its homepage uses, and the docs layout you're reading.

resources/views/vendor/aurora/layouts/standard.blade.php Blade
<x-layouts.site
    :title="$page->seoTitle()"
    :description="$page->meta_description ?: $page->excerpt"
    :canonical="$page->url()"
    :noindex="$page->noindex || $page->isRestricted() || $preview || $embedded"
    :page="$embedded ? null : $page"
>
    <x-aurora::blocks :page="$page" />
</x-layouts.site>
  • Every layout gets $page, $layout, $settings (the layout's own fields, below), $preview (a preview link, or a page that isn't live yet) and $embedded (drawn inside the visual editor's preview).
  • <x-aurora::blocks :page="$page" /> renders the page's blocks in the current language.
  • Adding a layout: in Settings › Templates › Layouts, give it a name, handle, icon and the Blade view it uses, which can be any view in your app. Make default makes any layout the default, including those defined in code. Pages choose their layout from cards with thumbnails, and preview links can show a page in another layout.
  • Shared pieces such as the header, menus and footer belong in components: Menu::location('header'), Setting::get(…), and the settings your blocks' library adds.

What Aurora serves

  • Pages at their address, in the layout they chose, and other languages under their prefix (/nb/om-oss). Drafts and scheduled pages answer 404 to visitors and show as previews to signed-in editors.
  • Signed preview links for drafts, scheduled pages, unpublished changes, revisions, other languages and other layouts.
  • sitemap.xml of live pages, without hidden, password-protected or members-only pages, and robots.txt, which keeps crawlers out of /admin and previews.
  • Password-protected pages unlock for the visit; members-only pages show a sign-in page. Publish aurora-views to restyle them.
  • Redirects, checked before a 404; the page cache; /files/{id}; and forms posted to /forms/{form}.

Turn aurora.routes off to route pages yourself with Aurora\Http\Controllers\PageController. How addresses are matched, where the website's own routes fit in, and how they get the site's layout with <x-aurora::layout>, is under Routing.

Fields of a layout's own v1.1.0

Some things a layout needs aren't blocks: a campaign layout's background image, say. Register fields for the layout's view from a service provider's boot():

app/Providers/AppServiceProvider.php PHP
use Aurora\Filament\Forms\Components\AssetPicker;
use Aurora\Support\Layouts;

Layouts::schema('layouts.campaign', fn (): array => [
    AssetPicker::make('background')
        ->label(__('Background image'))
        ->helperText(__('Shown behind the whole page.')),
]);
  • The page form shows them under the layout picker.
  • They're saved in the page's settings column, by view, so a field of the same name in another layout is kept apart.
  • The view reads its own from $settings, always with a fallback: pages saved before the fields existed don't have them.
  • Elsewhere, $page->layoutSettings() gives the page's values for its current layout, and $page->layoutSetting('background', $default) one of them.
  • AI tools read and set them (list_layouts, get_page, and layout_settings on create_page and update_page), so give each field a clear label and help text.
resources/views/layouts/campaign.blade.php Blade
<x-layouts.site :page="$page">
    <div class="relative">
        @if ($settings['background'] ?? null)
            <x-aurora::media :value="$settings['background']" size="lg" class="absolute inset-0 -z-10 size-full object-cover" />
        @endif
        <x-aurora::blocks :page="$page" />
    </div>
</x-layouts.site>

Layout fields, for now

A layout field has one value for every language, and the REST and GraphQL APIs don't return layout fields.

Layouts in code v1.2.0

A layout can also be defined in code: a class extending Aurora\Layouts\PageLayout. php artisan make:aurora-layout v1.2.2 asks for a name and what the layout is for, and makes both halves: the class in app/Layouts, and its view in resources/views/layouts, started from the site's standard layout.

~ Terminal
$ php artisan make:aurora-layout "Campaign" --description="Campaign pages: no menu, a big hero" --icon=phosphor-megaphone
app/Layouts/CampaignLayout.php PHP
namespace App\Layouts;

use Aurora\Filament\Forms\Components\AssetPicker;
use Aurora\Layouts\PageLayout;

class CampaignLayout extends PageLayout
{
    public static function handle(): string { return 'campaign'; }    // what pages know it by
    public static function name(): string { return __('Campaign'); }
    public static function view(): string { return 'layouts.campaign'; }
    public static function description(): ?string { return __('No menu, a big hero.'); }
    public static function icon(): ?string { return 'phosphor-megaphone'; }

    // Fields of its own, as with Layouts::schema().
    public static function schema(): array
    {
        return [AssetPicker::make('background')->label(__('Background image'))];
    }
}

Layout classes in app/Layouts (aurora.layout_path) v1.2.2 are offered to editors on their own, as blocks in app/Blocks are. A layout from elsewhere, such as a component library, is registered from a service provider's boot():

app/Providers/AppServiceProvider.php PHP
use Aurora\Support\Layouts;

Layouts::register([CampaignLayout::class]);
  • It's listed with the layouts added in the admin, and can be made the default there.
  • Its name, view and fields are the code's, so it can't be edited or deleted in the admin.
  • Changing handle() makes it a new layout: pages using the old handle don't follow.
  • Layouts in code need the migration that came with Aurora 1.2 (php artisan migrate).