javascripthtmlcssghost-blog

Ghost Blog give class current to menu item for pages


Is there a way to give class 'current' to active menu item in Ghost Blog. I need to give current class to highlight current menu item.

The following is working only for homepage.

{{#if current}} nav-current{{/if}}

Thanks.


Solution

  • I have the same problem. Works on my local machine but not on the server with Ghost 0.7.1 and no matter which Node version. So it’s not the themes fault.

    I contacted the folks in the ghost slack channel but nobody responded to this topic.

    So I just handle it via JS on the client side. Not that nice, but this works for me until they fix this issue.

    $('.nav a').each(function() {
        if($(this).attr('href') == window.location.href) {
            $(this).addClass('current');
        }
    });