Custom template for index.html

16 views
Skip to first unread message

Ken

unread,
May 21, 2020, 10:58:25 AM5/21/20
to sphinx-users
Any suggestions for how to add a custom template for the first/top page (index.html) for html output?

It looks like by default, Sphinx uses page.html (which in turn references layout.html), but it's not clear to me how to customize just one page (in this case the "home" page).

I've got html_additional_pages = {'index': 'index.html'} and html_theme_path is set to a local folder with my index.html template; however, my index.html template never seems to be used. BTW my custom layout.html template file in the same folder IS being used for all the pages, so I know Sphinx is at least finding my files.

Thanks!


Komiya Takeshi

unread,
May 21, 2020, 11:57:40 AM5/21/20
to sphinx...@googlegroups.com
Hi,

Unfortunately, there is no proper way to switch HTML templates only
for a specific page. In Sphinx doc, we use `html_additional_pages` to
copy static index.html, and change master_doc to "contents.rst" not to
conflict with static file.

Thanks,
Takeshi KOMIYA

2020年5月21日(木) 23:58 Ken <kennet...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/c4b43c97-e534-45bc-ac23-7b1c7f9a9d7f%40googlegroups.com.

Matt from Documatt

unread,
Jun 15, 2020, 3:51:09 AM6/15/20
to sphinx...@googlegroups.com
Hello Ken and Komia,
a little bit late to the party... I use exactly what you want to achieve on my recently launched blog https://blog.documatt.com (it's regular Sphinx project). Front page (index.rst) uses index.html template thanks to 
html_additional_pages = {
    'index': 'index.html',
}
The rest of the blog uses layout.html. I've just created a repo showing it. It includes output index.html under _build/html/.

Matt

Matt from Documatt

unread,
Jun 15, 2020, 4:45:14 AM6/15/20
to sphinx...@googlegroups.com

On Thu, May 21, 2020 at 4:58 PM Ken <kennet...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages