I've created my own homepage template [page--front.html.twig] and want to add the drupal default login and register form. I was looking for something like

{% include 'themes/bootstrap/templates/block--system-login.html.twig' %}

But it looks like none of these kind of blocks exist.

If I go to user/login and take a look into the source code (with devel enabled) I also do not see any block hint:

<div class="region region-content">

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'block' -->
   * block--flowers-content.html.twig
   * block--system-main-block.html.twig
   x block--system.html.twig
   * block.html.twig
<!-- BEGIN OUTPUT from 'themes/bootstrap/templates/block--system.html.twig' -->

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'form' -->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/form.html.twig' -->
<form class="user-login-form" data-drupal-selector="user-login-form" action="/user/login" method="post" id="user-login-form" accept-charset="UTF-8">

How can I add the login and register form in my (homepage)-Template? I did not find any useful information related to Drupal 8.

Any help is much appreciated. Thanks!


The user/login page is different from the the user login block. To add the user login form to an arbitrary page, then you would need to add the user login block to a region you want, and configure it to display only on the front page. This can be done using the Block administration page (documentation).


this is for register form in block

$entity = \Drupal::entityTypeManager()->getStorage('user')->create(array());
$formObject = \Drupal::entityTypeManager()
  ->getFormObject('user', 'register')
$form = \Drupal::formBuilder()->getForm($formObject);
print  \Drupal::service('renderer')->render($form);

tnx from otarza ♥♥♥

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.