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.
<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.xmlof live pages, without hidden, password-protected or members-only pages, androbots.txt, which keeps crawlers out of/adminand previews.- Password-protected pages unlock for the visit; members-only pages show a sign-in page. Publish
aurora-viewsto 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():
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
settingscolumn, 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, andlayout_settingsoncreate_pageandupdate_page), so give each field a clear label and help text.
<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>
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.
$ php artisan make:aurora-layout "Campaign" --description="Campaign pages: no menu, a big hero" --icon=phosphor-megaphone
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():
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).