Blade Templates in Laravel — a practical guide to Laravel Blade templates with clear examples you can reuse in real projects.
Laravel Tutorial Series (3/27). Prefer one page? Read the complete Laravel tutorial (all 27 topics).
Short description
Blade is Laravel’s templating engine. It compiles to plain PHP and supports layouts, components, escaping, and control structures.
Layout example
`resources/views/layouts/app.blade.php`:
<!DOCTYPE html>
<html>
<head>
<title>@yield('title', 'My App')</title>
</head>
<body>
<header>My Site</header>
<main>
@yield('content')
</main>
</body>
</html>
Child view
`resources/views/home.blade.php`:
@extends('layouts.app')
@section('title', 'Home')
@section('content')
<h1>Welcome, {{ $name }}</h1>
@endsection
Controller returning the view
return view('home', ['name' => 'Imtiyaj']);
Conditions and loops
@if ($posts->count())
@foreach ($posts as $post)
<article>{{ $post->title }}</article>
@endforeach
@else
<p>No posts yet.</p>
@endif
Escaping vs raw HTML
{{ $userInput }} {{-- escaped (safe) --}}
{!! $trustedHtml !!} {{-- unescaped (use carefully) --}}