views:

463

answers:

3
+2  Q: 

Sphinx templating

I am using sphinx. I want to template it. So after reading the docs, what I am trying is, in my conf.py,

I put a line like,

templates_path = ['_templates']

and I created a file

_templates/page.html

But this does not override the default template provided by sphinx. What more should I do, and where does this template need to go?


EDIT:

Directory structure from the comments:

conf.py
abc.txt
def.txt
makefile
_templates\
   page.html
A: 

The documentation http://sphinx.pocoo.org/templating.html#working-the-the-builtin-templates says that the template it's looking for is layout.html.

Perhaps you should use that name.

S.Lott
That template would be the one used to do layout, i believe. That would be needed, If say I wanted to change the position of sidebar. But I want to add something to the body. There is a template called page.html in sphinx/themes/basic/, which I want to override.
uswaretech
A: 

This works for me. Perhaps you need to force a rebuild for all files with the command sphinx-build -a? Sphinx only compiles HTML files that it detects as having changed. Another option is to just touch all your source files with touch *.rst.

Hao Lian
+1  A: 

Be sure you are using the theme name as an explicit directory in your template. e.g.:

{% extends "basic/layout.html" %}

see: HTML Theming Support

Kevin Horn