Change background for currentUser


I’m trying to have different backgrounds for logged and not logged in user.
I’ve tried the following code:

 {{#if currentUser}} 
<body style="background-image:url('img/bg.jpg');background-repeat: no-repeat;" >

<body style="background-image:none;background-repeat: no-repeat;" >

This doesn’t work either

<body {{#if currentUser}} style="background-image:none;" {{else}} style="background-image:url('img/bg.jpg');background-repeat: no-repeat;" {{/if}}>

Both are giving me complier errors.
What is working tho is:

<body style="background-image:url('img/bg.jpg');background-repeat: no-repeat;">
{{> template}}


Since body is not a template, you can’t really use template directives in it. Try this instead

    var body = document.getElementsByTagName('body')[0];
    if(Meteor.userId()) {
    } else {
1 Like

I need to remove a background (make it white) when user logs in

Solved the issue.
Added this to my login event handler, to change the background to white on login.{
 'submit .loginSubmit': function(event, template) {
  var email =;
  var password =;
  console.log(email, password);

 Meteor.loginWithPassword(email, password, function(err) {
  if (err) {
   Bert.alert(err.reason, 'danger' );

  if(!Meteor.userId()){ = "url('img/bg.jpg')";
  } else { = "none"; = "white";



Also added this on event when my first template is rendered.

Template.triphtml.rendered = function(){

  if(!Meteor.userId()){ = "url('img/bg.jpg')";
  } else { = "none"; = "white";