How to include header file in laravel

Updated at 21-Sep-2021, By samar

How to include header file in laravel

Through the use of the programming language, we will work together to solve the "How to include header file in laravel" puzzle in this lesson.

You can include a partial header file using @include() directive in laravel blade file
  • Include partial header file in laravel view

    //resources\views\home.blade.php
    @include('partials.header')
    
    //resources\views\partials\header.blade.php
    <div class="header">
        <a href="#default" class="logo">CompanyLogo</a>
        <div class="header-right">
            <a class="active" href="#home">Home</a>
            <a href="#contact">Contact</a>
            <a href="#about">About</a>
        </div>
    </div>
    

    Create the partial view file which you want to include in laravel view. Benefit of a partial header file is that you don’t have to use the header code again and again in different view files. You just have to use @include(‘path.file’) in the file and it's also useful in case you want to make changes because you just have to make changes in this particular partial header file instead of all files.

Back to code snippet queries related laravel