Search code examples
javascriptmeteorurl-routingiron-router

Meteor router for multiple layouts to use different layout for home


How to inherit the iron:router on only "homepage"... like whenever visitors visit the website...i'd like the different look without using nav bar.All other pages i want nav bar.but only for home ,i don't.So how do you inherit the use of iron:router only for 1 page? Can we do like this?

Router.configure({
	layoutTemplate: 'main'
});
Router.route('/',  {
template: 'TEMPLATENAME',
layoutTemplate: 'home'
});


Solution

  • From Meteor Routing and Layout

    Router.configure({
      // the default layout
      layoutTemplate: 'mainNav'
    });
    
    Router.route('/', function () {
      this.render('firstPage');
      this.layout('mainNav');
    });    
    
    Router.route('/second', function () {
      this.render('secondPage');
      this.layout('mainNav');
    });
    

    You should be able to set up multiple layouts and just specificy the page and the corresponding layout you want for it.

    EDIT: My first response was WAY off, sorry about that.