I want override the region default template. I did that with a hook theme from my module. I want override the region custom template but only for the front page. How can I do that?
1 Answer
You need to implement hook_theme_suggestions_HOOK_alter() in your theme. For siderbar_first region it would look like follows:
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function THEMENAME_theme_suggestions_region_alter(&$suggestions, $vars) {
if ($vars['elements']['#region'] == 'sidebar_first' && Drupal::service('path.matcher')->isFrontPage()) {
$suggestions[] = 'region__sidebar_first__front';
}
}
Now region--sidebar-first--front.html.twig can be used for theming sidebar on the front page.