Template Development

Templates allow you to control exactly how your Waravel pages look. Each template is a standard Laravel Blade file.

📍 Where are they?

Waravel looks for templates in:

resources/views/vendor/waravel/public-pages/templates/

Any .blade.php file you add here will automatically appear as a Template Option in the Page Editor dropdown.

🛠️ Creating a Template

Create a new file, for example landing-page.blade.php.

{{-- resources/views/vendor/waravel/public-pages/templates/landing-page.blade.php --}}

@extends('layouts.app') 

@section('content')
    

{{ $page->title }}

@if($page->hasMedia()) @endif
{{-- Render the WYSIWYG content --}} {!! $content !!}
@endsection

📦 Available Variables

Every template automatically receives these variables:

Variable Description
$page The full Page model instance. Access any attribute like $page->title, $page->slug, $page->created_at.
$content The HTML content from the editor. Note: You must allow unescaped HTML using {!! !!}.
$schemas A collection of Schema.org objects attached to the page.
$breadcrumbs An array of breadcrumb links for the current page hierarchy.
$children A collection of child pages (sub-pages) of the current page.

🎨 Best Practices

1. Extend Your Main Layout

Use @extends('layouts.app') to keep Waravel pages consistent with the rest of your site.

2. Use Components

Feel free to use your own <x-alert /> or @include partials inside templates.

3. Check for Media

Always use @if checks when displaying media.

@if($page->hasMedia())
    
    @foreach($page->media as $image)
            
    @endforeach
@endif