Laravel

How to Create Blade Template Layout in Laravel

Hello Laravel Friends,

Today we will learn about How to Create Blade Template Layout in Laravel.

The blade is a templating engine for the Laravel framework. Blade templating engine makes writing syntax easy and comfortable. Laravel Blade Template allows developers to create HTML-based smooth designs and themes. All the individual pages can extend the master template created with the blade template.

To create blade templates you just need to save your view file with the .blade.php extension rather than .php. Blade templates reside in the resources/views directory. Let’s find out How to Create Blade Template Layout in Laravel

Steps to Create Blade Template Layout in Laravel:

Step 1: Create a folder of your project name in the resources\views folder.

Step 2: Create layouts\partials folder in project_name folder

Step 3: Create header.blade.php, footer.blade.php and script/stylesheet.blade.php as per the requirement at the below path

resources\views\project_name\layouts\partials

Step 4: Create mainlayout.blade.php in the below path

resources\views\project_name\layouts

And add the following code to add header, footer, script, and stylesheet file

<!DOCTYPE html>
<html>
<head>
    <title>Project Name </title>
    @include('project_name.layouts.partials.stylesheet')//include stylesheet file
    @yield('styles') // for page specific stylesheet
</head>

<body>

@include('project_name.layouts.partials.script') // include script file
@include('project_name.layouts.partials.header') // include header file

@yield('content') //content part of page

@include('project_name.layouts.partials.footer') // include footer file

@yield('scripts') // for page specific script
</body>
</html>

Step 5: Include the mainlayout file as per your requirement and add sections.

@extends('project_name.layouts.mainlayout')
@section('styles')
//page specific style
@endsection
@section('content')
// write your page content here
@endsection
@section('script')
// code for page specific script
@endsection

Conclusion:

This way you can Create Blade Template Layout in Laravel. If you face any difficulty reach me via the comment box and Hire Dedicated Laravel Developers for your custom requirement. Stay tuned for the upcoming Laravel solutions.

Happy Coding

Click to rate this post!
[Total: 26 Average: 4.3]
Bharat Desai

Bharat Desai is a Co-Founder at MageComp. He is an Adobe Magento Certified Frontend Developer ? with having 8+ Years of experience and has developed 150+ Magento 2 Products with MageComp. He has an unquenchable thirst to learn new things. On off days you can find him playing the game of Chess ♟️ or Cricket ?.

Recent Posts

Top 10 Tips to Hire Shopify Developers

As the world of eCommerce continues to thrive, Shopify has become one of the most…

1 day ago

Managing Browser Events and Navigation in Shopify Remix: useBeforeUnload, useHref, and useLocation Hooks

Shopify Remix is an innovative framework that provides a streamlined experience for building fast, dynamic,…

1 day ago

Ultimate Guide to Hiring a Top Shopify Development Agency

Building a successful eCommerce store requires expertise, and for many businesses, Shopify has become the…

2 days ago

How to Choose the Best Shopify Development Company?

In today’s digital landscape, e-commerce has become a cornerstone for businesses looking to thrive. Among…

2 days ago

Flutter | Card Widget

Flutter is a popular UI toolkit that allows developers to create beautiful, natively compiled applications…

3 days ago

Resolving 403 Forbidden Errors in Chrome

The 403 Forbidden error is an everyday issue users may face while browsing the internet.…

3 days ago