cancel
Showing results for 
Search instead for 
Did you mean: 

Adding title and description inside head tag to custom phtml

Adding title and description inside head tag to custom phtml

Hi guys. I'm new at Magento. I'm going to make open graph meta tags inside the head tag. I made a custom phtml. I want to put title (og:title) and description (og:description) there. I have no idea how to make it dynamic. I want to make it the same as the current. Any variable to use? Thanks.

2 REPLIES 2

Re: Adding title and description inside head tag to custom phtml

You can add dynamic title and description using custom phtml file,

Create Static block and call static block from phtml file,

Call static block from Phtml file

 

Now you need to add your graph meta tag into Content -> Element -> Block

Call Block identifier using phtml file as per above link

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Adding title and description inside head tag to custom phtml

I just want to make og:title is the same as the title by system and og:description is the same as the description by title. Could I do that in default_head_blocks.xml? How to access the title and the description variable and put them in default_head_blocks.xml? Thanks.