Sometimes middle part of some page at our website may disappear and only header and footer are still displayed. The problem is always solved after flushing all caches.
Our html.html.twig
loads templates a way like
{% include '@themename/header.html.twig' %}
{{ page }}
{% include '@themename/footer.html.twig' %}
And our page.html.twig
loads an appropriate template depenging on the page path like
{% set path = path('<current>') %}
{% set pagePath = path|render|render %}
{% if pagePath == '/node' %} {# if homepage #}
{% include '@themename/homepage.html.twig' %}
{% else %}
{% include '@themename/innerpage.html.twig' %}
{% endif %}
We are not well familiar with Drupal caching so we don't know how exactly the problem is related to the caching. Maybe it's related somehow to render cache? As we use path|render|render
in our page.html.twig
. Or maybe it's related somehow to index.php
which is appeared sometimes in the address bar?
page--front.html.twig
template / suggestion you can use to target only the front page (whatever it's set to on the Basic Site Settings config page). Use that instead.