#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Layouts and Sections (@yield, @extends)

Most pages on a site share the same overall structure — a header, a footer, and a navigation bar — with only the middle content changing. Blade's layout system avoids duplicating that shared markup across every view.

Defining a Layout

A layout is just a regular Blade view that defines the common page structure, with one or more placeholders marking where child views should insert their own content. These placeholders are declared using @yield.

Extending a Layout

A child view declares which layout it belongs to using @extends, then fills in the placeholder using @section. Laravel merges the two together at render time, producing a complete HTML page.

DirectiveUsed InPurpose
@yield('content')Layout fileMarks where a child view's content should appear
@extends('layouts.app')Child viewDeclares which layout the view builds on
@section('content') ... @endsectionChild viewProvides the actual content for a named placeholder
@yield('title', 'Default')Layout fileYields a section with a fallback default value

Benefits of This Approach

Layouts solve page-level structure well, but for smaller, reusable pieces of UI — like a button or an alert — Laravel offers something more flexible: Blade components and slots.

Ready to master Laravel Training Course?

Join Uncodemy's hands-on Laravel program and build real, production-ready applications.

Explore Course