This doesn't work in my .phtml
file.
$head = $this->getLayout()->getBlock('head');
$head->setTitle("title blah");
$head->setDescription("description goes here");
$head->setKeywords("apples bananas coconuts");
To access this functionality, go to Stores -> Configuration -> Catalog -> Catalog -> Product Fields Auto-Generation. This is the place where you can set how to form product meta tags.
I believe you are going to want to put that code into your controller, not your view files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With