0
0
Laravelframework~30 mins

Including sub-views (@include) in Laravel - Mini Project: Build & Apply

Choose your learning style9 modes available
Including Sub-Views with @include in Laravel Blade
📖 Scenario: You are building a simple Laravel web page that shows a main content area and a footer. The footer is a separate part that you want to reuse on multiple pages.
🎯 Goal: Create a main Blade view that includes a footer sub-view using the @include directive.
📋 What You'll Learn
Create a Blade view file named footer.blade.php with a footer message.
Create a main Blade view file named main.blade.php with a heading and include the footer sub-view using @include.
Use the exact footer message: "This is the footer content."
Use the exact heading text: "Welcome to the Main Page"
💡 Why This Matters
🌍 Real World
Web developers often break pages into smaller parts like headers, footers, and sidebars to reuse them across many pages. This keeps code clean and easier to maintain.
💼 Career
Knowing how to include sub-views is essential for Laravel developers to build modular and maintainable web applications.
Progress0 / 4 steps
1
Create the footer sub-view
Create a Blade view file named footer.blade.php that contains a <footer> element with the text This is the footer content.
Laravel
Need a hint?

Use a <footer> tag and write the exact text inside it.

2
Create the main view with heading
Create a Blade view file named main.blade.php that contains an <h1> element with the text Welcome to the Main Page
Laravel
Need a hint?

Use an <h1> tag with the exact heading text.

3
Include the footer sub-view in the main view
In the main.blade.php file, add the Blade directive @include('footer') below the <h1> element to include the footer sub-view.
Laravel
Need a hint?

Use @include('footer') exactly to include the footer view.

4
Finalize the main view structure
Wrap the content in main.blade.php inside a <main> element and ensure the @include('footer') is inside this <main> block.
Laravel
Need a hint?

Use a <main> tag to wrap the heading and the include directive.