How to push metadata to head section from page
I create a filament page "Detail", I am accessing using
hostUrl/page/{slug}
and everytime I acces another page I want dynamic meta data, how can I push this meta data to <head>
sectionSolution:Jump to solution
For now I ended up like this, but if there any better way then I would be very appreciate
In render-hook page:
<meta name="description", content="@yield('meta_description', 'Default meta desc.')">
In filament page @section('meta_description'){{ $data->meta_desc }}@endsection
...5 Replies
Have you tried with a render hook?
https://filamentphp.com/docs/3.x/support/render-hooks
panels::head.start
Hi Patrick, using render hook could be working, I also think about this. But I am not sure how can I pass dynamic content everytime my url change.. For brief, when I go to
/first-page
I want to pass this firs-page meta, when visit /second-page
I want to push second-page meta and so on, so I am stuck (out of idea) when/how can I pass dynamic content to render-hook viewSolution
For now I ended up like this, but if there any better way then I would be very appreciate
In render-hook page:
<meta name="description", content="@yield('meta_description', 'Default meta desc.')">
In filament page @section('meta_description'){{ $data->meta_desc }}@endsection
Sounds like a good solution. I was thinking you could register the render hook from your page component
mount()
method.