Create a custom twig template for a form in Drupal 8

You are here

To create a custom twig template for a certain form in Drupal 8 you will need to add a theme suggestion hook in your .theme file like the suggestion below.

/**
 * Implements hook_theme_suggestions_HOOK() for contact form suggestion.
 */
function themename_theme_suggestions_form_alter(array &$suggestions, array $variables) {
    $suggestions[] = 'form__' . $variables['element']['#form_id'];
}