I want to create a login page. It would be a Single.

The URI is set to login. So how do I name and map the twig file?

I tried:

  • creating a login folder under templates.
  • naming the twig file either login.twig or index.twig
  • setting the template location to login/login.twig or login/index

Neither approach worked.

How do I setup a login page so that when I use requireLogin the login page is in the right location for loginPath. At the bare minimum, where is the easiest location to place the login path?

1 Answer 1


You didn't specify Craft 2 or 3, but I'm pretty sure this answer applies to both.

The template should live at templates/login/index.twig or templates/login.twig. Craft will resolve to both of them.

I tested this on a fresh Craft Pro install and created a Single with a template path of login. There is a templates/login.twig with the login example here: https://docs.craftcms.com/v3/dev/examples/login-form.html and a templates/test.twig that only has {% requireLogin %} in it.

I logged out of Craft, then went to mysite.com/test in a browser and was successfully redirected to mysite.com/login that rendered the example login template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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