How to include Common header and footer in Laravel Layout Blade File

In this tutorial we will discuss, how to include header and footer in laravel blade file or use of common layout file.

Include common header and footer in laravel blade

According to laravel standard way we make a layout file where included header, footer and common js and css files. Thus firstly we will make layout.blade.php file then include header and footer to this file. Now go to every separate blade(views) file and extends layout file. See in below example

View file layout/layout.blade.php

Create layout.blade.php file in layout folder or include header and footer which are make in same folder.

<html>
  <head>
  	<title>advanced web tuts</title>
  </head>
  <body>
  	@include('layout.header')

  		@yield('content')

  	@include('layout.footer')

  	@stack('js')
  </body>
</html>

@include() method is use for include common header and footer and @yield() method add content from all blade files.

View file front/home.blade.php

Now we make a home.blade.php view file in front folder and extends layout file here.

@extends('layout.layout')

@section('content')

	//Enter your content here

@endsection

@push('js')
 //Enter your js code here
@endpush

You read this tutorial on advanced web tuts provided by anmol sharma.

php laravel developer anmol sharma

Anmol Sharma

I am a software engineer and have experience in web development technologies like php, Laravel, Codeigniter, javascript, jquery, bootstrap and I like to share my deep knowledge by these blogs.

Random tutorial links