Skip to content

Laravel Facebook Open Graph Macro

Here is a custom HTML macros for Facebook Open Graph meta tags. if you don’t had any idea about FB open Graph meta tags , don’t worry visit my previous post : Facebook Open Graph META Tags

Laravel allowing us to extend the HTML facade with additional functionality. we use the HTML::macro() method to extend the HTML facade with our own methods.

Facebook Open Graph meta tags Macro

HTML::macro('fbog', function($property, $content)
{
return ''. PHP_EOL;
});

How to use:

Place the above macro code into your app/start/global.php file to register it. Then place place this code in your views.

{{ HTML::fbOgMeta("type","profile") }}
{{ HTML::fbOgMeta("title","Website Name"); }}
{{ HTML::fbOgMeta("description","Website  Description") }}
{{ HTML::fbOgMeta("image","https://website.com/image250X250.png") }}
{{ HTML::fbOgMeta("url","https://arjunphp.com") }}
{{ HTML::fbOgMeta("site_name","Website Name") }}
{{ HTML::fbOgMeta("see_also","https://arjunphp.com") }}

Output:

you may get below output in your html source












0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments