1

In order to make Google Page Speed score in green and our search ranking happy. We will need to have the above-the-fold css included in the head of our page template. This was possible in Drupal 7 where I got sites running nicely.

But things are changing in Drupal 8 for the better. What I basically want to do is this (I know it doesn't work).

In html.html.twig I want to insert this code into the

<style media="all">
  {% include '@mytheme/style/inline.css' %}
</style>

And then I expect it to look something like this in the front end.

<style media="all">
  html{background:#fff;color:#000;}body{margin:0;}...
</style>

Anyone have a solution for me? I do consider making Grunt output a inline.css.html.twig template instead of the inline.css but I fear that it might get ruined when being run though the twig engine!?

Thanks Jonas

Jonasdk
  • 151
  • 7

1 Answers1

0

I found the solution seems to be giving a full path to the file from root of the site.

<style media="all">
  {% include directory ~ '/style/inline.css' ignore missing %}
</style>

Update: I found the solution here Drupal 8 include part template

Community
  • 1
  • 1
Jonasdk
  • 151
  • 7