🎓 A1Learner
🔍
0 of 50 lessons completed

Laravel Blade Basics

Blade is the template language Laravel uses for views. A Blade file holds HTML, and Laravel turns it into a page.

Return a view

The route returns a view instead of plain text.

Route::get('/hello', fn () => view('hello'));

The view file

A Blade file holds HTML, and Laravel turns it into a page.

<h1>Hello Laravel!</h1>

Add more HTML

A view can hold any HTML, such as headings and paragraphs.

<h1>The Library</h1>
<p>Read Dune and Foundation.</p>

Example

Route::get('/hello', fn () => view('hello'));

<h1>Hello Laravel!</h1>

Key points

  • Blade: the template language Laravel uses to build HTML pages.
  • View: a Blade file that holds the HTML for one page.
  • Use view('hello') in a route to render the hello view.
  • Use the .blade.php ending for every Blade file.

In this example, the route returns the hello view. The view holds one heading. Laravel turns the view into a page. The page shows Hello Laravel!.

Note

Blade files live in resources/views, so hello.blade.php lives at resources/views/hello.blade.php.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What is a Blade view?