Search code examples
authenticationmeteornavbariron-router

Excluding the nav bar on certain pages in Meteor


I'm trying to create a meteor app where the login page shows nothing but my Welcome text and a sign in through Google. On my other pages I have a navbar. How do I exclude the navbar specifically from this login page? Does it have to do with iron:router? Is there some sort of special method that I call?


Solution

  • You can make 2 layouts like this.

        <template name="layout">
        <!-- Regular Stuff for the other pages You can place the navbar here -->
      {{> yield}}
        </template>
    
        <template name="layoutLogin">
        <!-- Just Login Pages -->
        {{> yield}}
        </template
    

    Now the Javascript Code.

    Router.map(function () {
      this.route('home', {
        path: '/',
        layoutTemplate: 'layout'}
                );
    });
    
       //Here we tell to render the template login, on the path /login and use the content on the layoutLogin
        Router.map(function () {
              this.route('login', {
                path: '/login',
                layoutTemplate: 'layoutLogin'}
                        );
            });
    

    Tell me if works.