You just add them in your blade files. They are normal HTML tags.
Meta Tags and other Seo Features
I want to add meta tags like Open Graph taking the post title and link and Twitter Card to my laravel project, does anyone have idea on how i can?
@ftiersch is right there. Here is a working example from a project where @bobbybouwmann and I are working on.
<meta property="og:site_name" content="Laravel Secrets">
<meta property="og:title" content="Laravel Secrets">
<meta property="og:description" content="">
<meta property="og:type" content="website">
<meta property="og:locale" content="en">
<meta property="og:url" content="https://laravelsecrets.com/">
<meta property="og:image" content="{{ asset('img/generic_summary_card.png') }}">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Build your knowledge with the hidden Laravel Secrets you find in this book. Learn about the why and not the what.">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@stefanbauerme">
<meta name="twitter:creator" content="@stefanbauerme">
<meta name="twitter:title" content="Laravel Secrets">
<meta name="twitter:image" content="{{ asset('img/twitter_summary_card.png') }}">
@stefanbauer Very useful !!
What if the contents on each pages are different. you can not just add them. You need to specify.
How can you do that?
You could use a Post title if available, or default to a generic site title.
<meta property="og:title" content="{{ $post->title ?? 'Your Default Title' }}">
If you want more control, then you can have a section in the <head> of your layout view template which you can use to yield your custom tags.
Made an package to make it easier for developer to make frontend seo optimized.
Here is the link: https://khanaldipesh.com.np/package/laravel-seo-manager
Would love to get your feedback or maybe PRs.
Please or to participate in this conversation.