# Secondary logo (Hack)

**URL:** <https://forum.ghost.org/t/secondary-logo-hack/21454>\
**Category:** Themes\
**Created:** [April 1, 2021, 10:52pm UTC](https://forum.ghost.org/t/secondary-logo-hack/21454 "2021-04-01T22:52:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raz1](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/raz1/32/12421_2.png) [@Raz1](https://forum.ghost.org/u/Raz1)\
**Post date:** [April 1, 2021, 10:52pm UTC](https://forum.ghost.org/t/secondary-logo-hack/21454/1 "2021-04-01T22:52:08Z")

</div>

I managed to hack myself a secondary logo in my theme. However, it does require the user to add a symbol into the assets folder.

**Backstory**  
My PNG logo wasn’t doing any justice on dark-mode, and I knew I couldn’t rely on users to use SVG correctly, as suggested in another post.

**How it works**  
The user can upload a publication logo on the Ghost dashboard, and a secondary logo hosted in the themes asset folder when they switch to dark-mode.

**TL;DR Solution**

I created an image folder in the assets folder containing ‘logo-dark.png’. That’s my dark logo.

```
assets/logo-dark.png

```

I created a new partial containing the logo:

```
<a class="logo " href="{{@site.url}}">
    {{#if @site.logo}}
        <img id="logo-light" src="{{@site.logo}}" alt="{{@site.title}}">
        <img id="logo-dark" class="hidden" src={{asset "images/logo-dark.png"}} alt="{{@site.title}}">
    {{/if}}
</a>

```

In my main.js, when the dark mode is active, I hide the publication logo.

My theme has jQuery, but you can 100% code it with vanilla JS. There are multiple ways to apply the same principle, including switches, but this is my approach.

```
function darkMode() {
    $('.toggle-track').on('click', function () {
        if (html.hasClass('dark')) {
            html.removeClass('dark');
            $('#logo-light').removeClass('hidden')
            $('#logo-dark').addClass('hidden')
        } else {
            html.addClass('dark');
            $('#logo-light').addClass('hidden')
            $('#logo-dark').removeClass('hidden')
        }
    });
}

```

* * *

Now, whenever I toggle dark-mode, it also changes my logo! The end-user has to upload a publication logo and also change the logo in the themes asset folder.

I’m a coding newbie and far from being a developer, hacking and trying as I go! Any feedback is appreciated.

I removed some fluff from the code for easy reading, but ideally, you’d want to save your settings into the browser local storage.

 ![Publication logo uploaded on Ghost](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/2/25ffdc3c31c58e4aa57258ccf73b17fc638e5a82.jpeg)  
Publication logo

 ![Secondary logo dark-mode hack](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/b/bcb82a4189f67c8336aaf230fad566b9b26d0450.jpeg)  
Secondary logo
