Using Laravel Blade’s @yield and @section directives

When you want to include content from various locations in your template files or loops, it can be useful in certain situations. For instance, in index.blade.php, you may require the content from master.blade.php. The result of this is as follows:
Solution 2 can be to use a stack in your scripts, which allows you to append as much content as required. To specify a directory, you can use the following example: if your main.blade.php is located in a particular directory, it could be something like:
Solution 2 suggests that you make changes to your code for ‘p’ like this:
Hopefully, this will work for you. The question is about trying to yield a section inside another section that has already been yielded in [unknown location], but it is not functioning correctly.


on my main.blade.php


on my home.blade.php


this content should show on my main


I am facing an issue where my @section content is not displaying despite having no errors. I am using Laravel 5.4 and cannot seem to figure out what could be causing this problem.

Solution 1:

Ensure that your main.blade.php and home.blade.php are located within the



Use the ” . ” symbol to indicate a different directory if it is not the same as the current directory.

Suppose the main.blade.php file is located at


, in that case, the code snippet would resemble



Solution 2:

It appears that an update to the code for

is necessary, specifically for the section related to variable “p”.




Hope this work for you

Frequently Asked Questions

Posted in Php