How to add links to the sidebar

497 views
Skip to first unread message

Oscar Benjamin

unread,
Jan 17, 2021, 6:23:12 AM1/17/21
to sphinx...@googlegroups.com
Hi,

Is there a simple way to tell Sphinx to add some links to the sidebar
in the HTML output for the classic theme?

I'm trying to migrate the SymPy doc build from Travis to Actions and
I'm wondering if there's a better way of adding sidebar links.

You can see the sidebar links here:
https://docs.sympy.org/latest/index.html

In particular it has:

Documentation version
SymPy 1.7.1 (latest release)
SymPy 1.8.dev (development version)

At the moment those links are added by post-processing the HTML output
from Sphinx using this script which also does some other redundant
things that are no longer needed:
https://github.com/sympy/sympy_doc/blob/gh-pages/generate_indexes.py

Related sympy issue:
https://github.com/sympy/sympy_doc/issues/46

I think it would be cleaner if we could tell Sphinx to add those links
and avoid any post-processing of the output from Sphinx but I'm not
sure how to do it...

Oscar

Komiya Takeshi

unread,
Jan 18, 2021, 11:15:46 AM1/18/21
to sphinx...@googlegroups.com
Hi,

How about using `html_sidebars`? It allows you to insert custom
sidebar-parts to your pages.
https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_sidebars

1. Create a partial HTML as a template file
2. Put it template dir on your project (ex. _templates)
3. Check `templates_path` configuration contains above template dir
4. Set up your custom sidebar via `html_sidebars`

Thanks,
Takeshi KOMIYA

2021年1月17日(日) 20:23 Oscar Benjamin <oscar.j....@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/CAHVvXxRkkNfFT9twcVV%3DzB51zbOX2OmM_j9Dp6MkxE6To23vVw%40mail.gmail.com.

Oscar Benjamin

unread,
Jan 19, 2021, 7:18:08 AM1/19/21
to sphinx...@googlegroups.com
Hi Komiya~San,

Thanks, that looks like exactly what I wanted. I'll give that a try
when I find time to get back to this.

Oscar
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/CAFmkQANgyxGfR61MX1Lyj0uvLO-_RQALG0boX%2Bcz_95XYcE-YQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages