Skip to main content
added 196 characters in body
Source Link
Ondrej
  • 227
  • 4
  • 15

I have a theme that uses several template files like page.html.twig, page--title.html.twig, etc.

I installed Metatag to make my website more understandable when sharing links to it via LinkedIn. However, after installing the Metatag module, my tags in all pages except admin are blank. I also tried to specify the title tag's content within Metatag as [current-page:title] | [site:name], but the title tag is still empty

I know this is a common issue. I have found this online

When using custom page template files, e.g., page--front.tpl.php, it is important to ensure that the following code is present in the template file: <?php render($page['content']); ?> or <?php render($page['content']['metatags']); ?>. Without one of these being present the meta tags will not be displayed.

However, that looks like an advice for Drupal 7 only - and I don't know how to do this in a TWIG file used by Drupal 8. Any advice would be appreciated.

EDIT: My TWIG files are as follows:

I have a theme that uses several template files like page.html.twig, page--title.html.twig, etc.

I installed Metatag to make my website more understandable when sharing links to it via LinkedIn. However, after installing the Metatag module, my tags in all pages except admin are blank. I also tried to specify the title tag's content within Metatag as [current-page:title] | [site:name], but the title tag is still empty

I know this is a common issue. I have found this online

When using custom page template files, e.g., page--front.tpl.php, it is important to ensure that the following code is present in the template file: <?php render($page['content']); ?> or <?php render($page['content']['metatags']); ?>. Without one of these being present the meta tags will not be displayed.

However, that looks like an advice for Drupal 7 only - and I don't know how to do this in a TWIG file used by Drupal 8. Any advice would be appreciated.

I have a theme that uses several template files like page.html.twig, page--title.html.twig, etc.

I installed Metatag to make my website more understandable when sharing links to it via LinkedIn. However, after installing the Metatag module, my tags in all pages except admin are blank. I also tried to specify the title tag's content within Metatag as [current-page:title] | [site:name], but the title tag is still empty

I know this is a common issue. I have found this online

When using custom page template files, e.g., page--front.tpl.php, it is important to ensure that the following code is present in the template file: <?php render($page['content']); ?> or <?php render($page['content']['metatags']); ?>. Without one of these being present the meta tags will not be displayed.

However, that looks like an advice for Drupal 7 only - and I don't know how to do this in a TWIG file used by Drupal 8. Any advice would be appreciated.

EDIT: My TWIG files are as follows:

Source Link
Ondrej
  • 227
  • 4
  • 15

<title> blank after installing Metatag

I have a theme that uses several template files like page.html.twig, page--title.html.twig, etc.

I installed Metatag to make my website more understandable when sharing links to it via LinkedIn. However, after installing the Metatag module, my tags in all pages except admin are blank. I also tried to specify the title tag's content within Metatag as [current-page:title] | [site:name], but the title tag is still empty

I know this is a common issue. I have found this online

When using custom page template files, e.g., page--front.tpl.php, it is important to ensure that the following code is present in the template file: <?php render($page['content']); ?> or <?php render($page['content']['metatags']); ?>. Without one of these being present the meta tags will not be displayed.

However, that looks like an advice for Drupal 7 only - and I don't know how to do this in a TWIG file used by Drupal 8. Any advice would be appreciated.