The invocation of theDrupal 8 doesn't use hook_html_head_alter()
was removed from Drupal core.
Issue - Its usage has been removed in Remove invocation of hook_html_head_alter().
D8 has a new hook As described in drupal_add_*() deprecated in favour of #attached, in Drupal 8 is possible to achieve ituse :hook_page_attachments()
and hook_page_attachments_alter().
Code fromhook_page_attachments_alter()
, for example using code similar to the change recordfollowing one, suggested in :one of the comments for the change record.
function MYTHEME_page_attachments_alter(array &$page) {
$viewport = [
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => [
'name' => 'viewport',
'content' => 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no',
],
];
$page['#attached']['html_head'][] = [$viewport, 'viewport'];
}
function MYTHEME_page_attachments_alter(array &$page) {
$viewport = [
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => [
'name' => 'viewport',
'content' => 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no',
],
];
$page['#attached']['html_head'][] = [$viewport, 'viewport'];
}