SEO::title(...) missing after refresh / on inital pageload
J87NL opened this issue · 7 comments
- Laravel Version: 10.13.5
- PHP Version: 8.2.7
- Splade JS Version (npm): 1.4.15
- Splade PHP Version (composer): 1.4.15
Description:
SEO::title(...)
's are working great when navigating through our Splade application using <Link
's, but they dissapear after a page refresh and on the inital pageload.
Steps To Reproduce:
In my controllers I use
<?php
namespace App\Http\Controllers;
// ...
use ProtoneMedia\Splade\Facades\SEO;
class TestController extends Controller
{
public function index()
{
SEO::title(__('A fancy title'));
return view('index');
}
When I navigate to this page using the menu the title is there, when I refresh it is gone.
Perhaps related: visiting a page from your local history sometimes opens the expected page (based on the title), sometimes a different one.
Anyone had found a way to fix this behavior?
@J87NL which browser are you using? I can't seem to reproduce it on Chrome and Firefox.
Hi Pascal, thanks for your reply! I have this behavior in both Firefox 116.0 (64-bits) and Chrome 115.0.5790.110 (64-bits) on Ubuntu 22.04.2 LTS.
@pascalbaljet Are you testing with SSR enabled? I'm without ssr enabled and this happens both in local and production, chrome and safari.
I had the same issue. Make sure you remove the <title>
tag and have @spladeHead
in your root.blade.php
file.
Thanks @romain-lgr, you are right. This fixes the refresh-issue.
Not sure but I guess the <title>
-tag is added when using https://github.com/protonemedia/laravel-splade-breeze starter kit.
However: this doesn't seem to fix the page history issue.