Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lara1376's avatar

Include section from Blade template

Hi,

Say I have a Blade template like this, saved in resources/views/posts/show.blade.php:

@extends('layout.default')

@section('header')
single post title
@stop

@section('content')
single post content and other things
@stop

I know I can @include('posts.show') in another template, which is great. However, can I just @include() a part of this template, like the content section?

If I can avoid it I don't want to create another template to solve this problem, I was just wondering if there's a way to include a section of a template rather than the whole thing?

0 likes
2 replies
lollypopgr's avatar

try this

view('posts.show')->renderSections()['content'] 
Snapey's avatar

Thats not really how it works.

This view delegates to the master layout and the master layout yields back to the sections in this view.

If you included this in another view it would get very confusing because of the master layout.

Better option would be to @include the content and then @include that same content in another view.

page1 with default layout;

@extends('layout.default')

@section('header')
single post title
@stop

@section('content')
    @include(' _content')
@stop

_content.blade.php

single post content and other things

page2 with customised layout

@extends('layout.customised')

@section('header')
single post title
@stop

@section('content')
    @include(' _content')
@stop

Please or to participate in this conversation.