title: Undefined variable: title (View: C:\xampp\htdocs\myproject\resources\views\categories\index.blade.php)
body: <p>I try to make a page index.blade, but i getting error</p>
  
  <p>Undefined variable: title (View: C:\xampp\htdocs\myproject\resources\views\categories\index.blade.php)</p>
  
  <p>I am using laravel 5.4 PHP 7.0.33
  Is there anything wrong with the code?</p>
  
  <p><strong>My Controller</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  use App\Category;
  
  use Illuminate\Http\Request;
  
  class CategoryController extends Controller
  {
      /**
       * Display a listing of the resource.
       *
       * @return \Illuminate\Http\Response
       */
      public function index()
      {
          $categories = Category::orderBy('created_at', 'DESC')-&gt;paginate(10);
          return view('categories.index', compact('categories'));//
      }
  </code></pre>
  
  <p><strong>My index.blade</strong>
  this is my view/categories/index.blade.php</p>
  
  <pre><code>@extends('layout.master')
  ​
  @section('title')
      &lt;title&gt;Manajemen Kategori&lt;/title&gt;
  @endsection
  ​
  @section('content')
      &lt;div class="content-wrapper"&gt;
          &lt;div class="content-header"&gt;
              &lt;div class="container-fluid"&gt;
                  &lt;div class="row mb-2"&gt;
                      &lt;div class="col-sm-6"&gt;
                          &lt;h1 class="m-0 text-dark"&gt;Manajemen Kategori&lt;/h1&gt;
                      &lt;/div&gt;
                      &lt;div class="col-sm-6"&gt;
                          &lt;ol class="breadcrumb float-sm-right"&gt;
                              &lt;li class="breadcrumb-item"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
                              &lt;li class="breadcrumb-item active"&gt;Kategori&lt;/li&gt;
                          &lt;/ol&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  ​
          &lt;section class="content"&gt;
              &lt;div class="container-fluid"&gt;
                  &lt;div class="row"&gt;
                      &lt;div class="col-md-4"&gt;
                          @card
                              @slot('title')
                              &lt;div class="card"&gt;
                                  &lt;div class="card-header with-border"&gt;
                                   &lt;h3 class="card-title"&gt;{{ $title }}&lt;/h3&gt;
                              &lt;/div&gt;
                              &lt;div class="card-body"&gt;
                                  {{ $slot }}
                              &lt;/div&gt;
                                  {{ $footer }}
                              &lt;/div&gt;
                              @endslot
  
                              @if (session('error'))
                                  @alert
                                  &lt;div class="alert alert-{{ $type }} alert-dismissible"&gt;
                                      {{ $slot }}
                                  &lt;/div&gt;
                                  @endalert
                              @endif
  ​
                              &lt;form role="form" action="{{ route('kategori.store') }}" method="POST"&gt;
                                  @csrf
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="name"&gt;Kategori&lt;/label&gt;
                                      &lt;input type="text" 
                                      name="name"
                                      class="form-control {{ $errors-&gt;has('name') ? 'is-invalid':'' }}" id="name" required&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="description"&gt;Deskripsi&lt;/label&gt;
                                      &lt;textarea name="description" id="description" cols="5" rows="5" class="form-control {{ $errors-&gt;has('description') ? 'is-invalid':'' }}"&gt;&lt;/textarea&gt;
                                  &lt;/div&gt;
                              @slot('footer')
                                  &lt;div class="card-footer"&gt;
                                      &lt;button class="btn btn-primary"&gt;Simpan&lt;/button&gt;
                                  &lt;/div&gt;
                              &lt;/form&gt;
                              @endslot
                          @endcard
                      &lt;/div&gt;
                      &lt;div class="col-md-8"&gt;
                          @card
                              @slot('title')
                              List Kategori
                              @endslot
  
                              @if (session('success'))
                                  @alert(['type' =&gt; 'success'])
                                      {!! session('success') !!}
                                  @endalert
                              @endif
  
                              &lt;div class="table-responsive"&gt;
                                  &lt;table class="table table-hover"&gt;
                                      &lt;thead&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;#&lt;/td&gt;
                                              &lt;td&gt;Kategori&lt;/td&gt;
                                              &lt;td&gt;Deskripsi&lt;/td&gt;
                                              &lt;td&gt;Aksi&lt;/td&gt;
                                          &lt;/tr&gt;
                                      &lt;/thead&gt;
                                      &lt;tbody&gt;
                                          @php $no = 1; @endphp
                                          @forelse ($categories as $row)
                                          &lt;tr&gt;
                                              &lt;td&gt;{{ $no++ }}&lt;/td&gt;
                                              &lt;td&gt;{{ $row-&gt;name }}&lt;/td&gt;
                                              &lt;td&gt;{{ $row-&gt;description }}&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;form action="{{ route('kategori.destroy', $row-&gt;id) }}" method="POST"&gt;
                                                      @csrf
                                                      &lt;input type="hidden" name="_method" value="DELETE"&gt;
                                                      &lt;a href="{{ route('kategori.edit', $row-&gt;id) }}" class="btn btn-warning btn-sm"&gt;&lt;i class="fa fa-edit"&gt;&lt;/i&gt;&lt;/a&gt;
                                                      &lt;button class="btn btn-danger btn-sm"&gt;&lt;i class="fa fa-trash"&gt;&lt;/i&gt;&lt;/button&gt;
                                                  &lt;/form&gt;
                                              &lt;/td&gt;
                                          &lt;/tr&gt;
                                          @empty
                                          &lt;tr&gt;
                                              &lt;td colspan="4" class="text-center"&gt;Tidak ada data&lt;/td&gt;
                                          &lt;/tr&gt;
                                          @endforelse
                                      &lt;/tbody&gt;
                                  &lt;/table&gt;
                              &lt;/div&gt;
                              @slot('footer')
  ​
                              @endslot
                          @endcard
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/section&gt;
      &lt;/div&gt;
  @endsection
  </code></pre>
  
  <p><strong>My route web.php</strong></p>
  
  <pre><code>Route::resource('/kategori', 'CategoryController', 
                  ['except' =&gt; ['create', 'show']]);
  </code></pre>