title: Laravel - @yield() not allowed in if
body: <p>In my title I've been using @yield('title') for a while to create a dynamic title for every different page. I'd like to take it one step further and do something like this:</p>
  
  <pre><code>@if(@yield('title') == 'post') 
       &lt;h1&gt; This is the post page &lt;/h1&gt;
  @endif
  </code></pre>
  
  <p>But if I try that I get the error:</p>
  
  <p>"The "yield" expression can only be used inside a function"</p>
  
  <p>I've searched around and found things like Section::yield('title') but they all didn't work.</p>
  
  <p>How can I use the value of @yield('title') in an if statement?
  I know you can send a $title to the view from the controller but I dont think that looks very good.. You would have to define the title twice that way.</p>
  
  <p>Thanks for reading!</p>