The extrahead block in layout.html

357 views
Skip to first unread message

Tarek Ziadé

unread,
Sep 2, 2008, 5:00:39 AM9/2/08
to sphin...@googlegroups.com
Hello

I have customized my Sphinx look and feel, by overriding layout.html like this:

====
{% extends '!layout.html' %}

{% block extrahead %}
<link rel="stylesheet"
  href="{{ pathto('_static/mine.css', 1) }}"
    type="text/css" />
{% endblock %}
====

The problem is, some pages in Sphinx already override it, like: modindex.html
so the css is not added in them, and I need to create custom templates for them too.

Wouldn't it be better to have a dedicated block for customisation in the head, that is *never*
used by any template provided by Sphinx, so the change can be applied to all pages ?

Although I have seen that search.html in the trunk does not have this block anymore..

Regards
Tarek


--
Tarek Ziadé | Association AfPy | www.afpy.org
Blog FR | http://programmation-python.org
Blog EN | http://tarekziade.wordpress.com/

Georg Brandl

unread,
Sep 6, 2008, 12:31:01 PM9/6/08
to sphin...@googlegroups.com
Tarek Ziadé schrieb:

> Hello
>
> I have customized my Sphinx look and feel, by overriding layout.html
> like this:
>
> ====
> {% extends '!layout.html' %}
>
> {% block extrahead %}
> <link rel="stylesheet"
> href="{{ pathto('_static/mine.css', 1) }}"
> type="text/css" />
> {% endblock %}
> ====
>
> The problem is, some pages in Sphinx already override it, like:
> modindex.html
> so the css is not added in them, and I need to create custom templates
> for them too.
>
> Wouldn't it be better to have a dedicated block for customisation in the
> head, that is *never*
> used by any template provided by Sphinx, so the change can be applied to
> all pages ?
>
> Although I have seen that search.html in the trunk does not have this
> block anymore..

You're quite right that this is bad; the bug is in the templates overriding
extrahead, they should call ``super()`` properly to allow for content in
the parent template.

I'll fix this ASAP.

Georg

Reply all
Reply to author
Forward
0 new messages