How to include header file in laravel

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

Answers 1
  • 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>
    
    0

    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