7

I am working on a small project and I thought I'd give wagtail a try. I am now wondering how I could change wagtail's admin logo in the sidebar (top left image on the picture bellow).

github wagtail image

I could change /static/wagtailadmin/images/wagtail-logo.svg directly but it'd be wrong ;).

Dhia
  • 10,119
  • 11
  • 58
  • 69
GabLeRoux
  • 16,715
  • 16
  • 63
  • 81

2 Answers2

10

Wagtail already provide the solution in the official documentation using django-overextends:

To replace the default logo, create a template file your_app/templates/wagtailadmin/base.html that overrides the block branding_logo as follow:

{% overextends "wagtailadmin/base.html" %}

{% block branding_logo %}
    <img src="{{ STATIC_URL }}images/custom-logo.svg" alt="Custom Project" width="80" />
{% endblock %}

Check Wagtail Custom branding for more details.


(Edit Dec - 2020)

Note: In the latests versions of Wagtail django-overextends is not needed anymore. It uses now the default extends tag of Django templates. Consult the docs for more information

Yasiel Cabrera
  • 540
  • 4
  • 11
Dhia
  • 10,119
  • 11
  • 58
  • 69
  • 2
    Cool, this documentation was added on `v1.0` and wasn't released at the time of writing question, thanks for sharing this :) This seems like the right answer now – GabLeRoux Jan 29 '16 at 17:26
  • 1
    Now, 4 years after this answer was wrote, `django-overextends` is not needed anymore. [See the docs](https://docs.wagtail.io/en/v2.11.3/advanced_topics/customisation/admin_templates.html) – Yasiel Cabrera Dec 13 '20 at 16:40
  • 1
    @YasielCabrera thanks for sharing. Would you please add it as a Note at the beginning of the response, I will approve it. – Dhia Dec 15 '20 at 11:37
9

The logo is defined here:

https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailadmin/templates/wagtailadmin/base.html#L7

To override it, you'll need an app which contains templates/wagtailadmin/base.html and precedes wagtail in INSTALLED_APPS.

Good luck!

GabLeRoux
  • 16,715
  • 16
  • 63
  • 81
tomd
  • 1,373
  • 1
  • 8
  • 12
  • 3
    Thanks!, I didn't know I needed to have my app in front of others to override templates, very useful. I just found that when using `TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates'),)` in settings, templates placed in this directory also overrides other apps so no need to mess with app order :) – GabLeRoux Jul 02 '14 at 19:51
  • 3
    A more in-depth explanation can be found in the current wagtail documentation (http://docs.wagtail.io/en/v1.0b1/howto/custom_branding.html). Also, *django-overextends* is a great way to override 3rd-party templates cleanly. – jnns Sep 15 '15 at 12:25