Change of Logo Results in Division by Zero

My objective: To change the text “Grav” to logo image.


  1. My website is
  2. I am using bootrap as my default them
  3. I want to change the text to an image.
  4. I create “images” folder and uploaded favicon.ico and logo.png under user/themes/bootstrap
  5. Searched the tutorial and found that I have to change the code in ~/user/themes/bootstrap/templates/navigation/partials/navigation.html.twig and replace the code with:

<a href=“{{ baseurl == ‘’ ? ‘/’ : baseurl }}”>

  1. On reloading, I got this error message " Twig_Error_Runtime
    An exception has been thrown during the rendering of a template (“Division by zero”).". The offending code is pointing the above.

I am not too sure what should be the url.

Any pointer is highly appreciated.

Thanking all in advance.

M A Sani

I think you’re missing the _ in your baseurl which is probably causing that error. This is what I’m using for logo:

<a href="{{ base_url == '' ? '/' : base_url }}" class="navbar-brand"><img src="{{ base_url }}/images/logos/logo.png" class="logo" alt="logo" title="Home"></a>

However I’ve got my logo in an images folder in my pages folder rather than within the theme.


I wasn’t able to reply earlier due to the status of my account.

I tried your suggestion. It worked with a small problem. Everytime, I refreshed, the folders and the images are gone. I thought was a cPanel issue. Then, I tried putting them (the images) under the user/images/logos/. It worked like a charm.

I really appreciate your assistance. Thanks a lot and take care.