1

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:

5
  • can you share your page.html.twig and html.html.twig source codes?
    – Yuseferi
    Commented Mar 28, 2017 at 8:02
  • Thanks, zhilevan. I edited the question and added the code.
    – Ondrej
    Commented Mar 28, 2017 at 8:10
  • Ping :) I'll be grateful for any advice on this.
    – Ondrej
    Commented Mar 29, 2017 at 13:35
  • your files seems Ok, I should test it by myself, do you develop your theme based on specified theme like boostrap theme or zen or omega? I mean what is your base and starter theme?
    – Yuseferi
    Commented Mar 29, 2017 at 19:24
  • I have developed it from scratch few years back. However, I don't think the theme would be a problem - as I wrote above, I read online that this is a common issue related to the Metatag module and that one has to call the methods above - but that's PHP, so it would be usable in D7 .tpl files, not in TWIG in D8 - and that's the question, I think: how to call this in a D8 TWIG template.
    – Ondrej
    Commented Mar 30, 2017 at 5:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.