Login Plugin: Show log in, if not logged in, shot logout if logged in


i’am building a login area. I’am using the standard login plugin.

But my problem is, if i’am not logged in, there should be a link like “login” and if i’am logged in, there should be a link like “logout”.

I;ve added this snippet:

{% if config.plugins.login.enabled and grav.user.username %}

  • {% include ‘partials/login-status.html.twig’ %}

  • {% endif %}

    and it shows me a logout link, but when i click it, it gives me this error:

    “Forbidden You don’t have permission to access on this server.”


    I added the page “register”. But If i’am clicking on it, a white Page is showing without a registerformular.

    Anny suggestions?


    Also: If i direct to “login” and click on logg out there, it works. But if i click on logout in the navigation, it will not work.

    Edit: The logout only works, if i’am NOT on the Home Site.

    Got some major-ish updates coming to Login plugin soon. I hope some of these will address the issues you are seeing. You can test with the current “develop” version in the Login github repo.

    1 Like

    @rhuk great work with the login.

    I’m also looking for this functionality to have a link in the menu with the appropriate prompts login/register if user not logged in and hello user, logout according to the current state. Is there a standard way to do this now?

    Note that I can see the Conditional “{{hello user name message}} Logout” when user logged in but not the “{{hello stranger message}} Login”


    Hi @nargetdev, hope this article gets you a step closer to your goal :slight_smile:

    Is this possible at this point with the login plugin, I would like to have this as well

    Similar questions have been asked before. A search for “logged in menu” in this forum will give you a good overview of these.

    Hi this one is still on my list and don’t know how to achieve this. Can someone help me out?

    My navigation template is

    <ul class="nav navbar-nav navbar-right ">
    {% for page in pages.children.visible %}
    {% set active_page = (page.active or page.activeChild) ? 'active' : '' %}
            <a href="{{ page.url }}" class="{{ active_page }}">
                {{ page.menu }}
    {% endfor %}

    I would like to have login and logout text in the menu (last item) based on status.


    I did try adding this which works fine to show logout when loggedin

    	{% if config.plugins.login.enabled and grav.user.username %}
        <li><i class="fa fa-lock"></i> {% include 'partials/login-status.html.twig' %}</li>
    {% endif %}

    But then i need to add an extra login link in the menu which should be invisible once logged in. Only available when anonymous. Not sure how to do that.