Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure sidebars for singlehtml #5246

Closed
davidism opened this issue Aug 1, 2018 · 2 comments
Closed

Configure sidebars for singlehtml #5246

davidism opened this issue Aug 1, 2018 · 2 comments

Comments

@davidism
Copy link

davidism commented Aug 1, 2018

It's common to configure one set of sidebars for the index and another set for all other pages. For example, the index page will show project links in the sidebar and the full table of contents in the body, while other pages will show the local table of contents and navigation.

html_sidebars = {
    'index': [
        'project.html',
        'versions.html',
        'searchbox.html',
    ],
    '**': [
        'localtoc.html',
        'relations.html',
        'versions.html',
        'searchbox.html',
    ]
}

When using the singlehtml builder, the page name is always "index". It would be desirable to show the table of contents in the sidebar for this builder, since due to #2589 the table of contents is replaced by the pages and won't show up in the body. But since the page name is "index", it uses the index sidebars configured for the regular html builder.

A solution to this would be to add a singlehtml_sidebars = [] configuration, and fall back to the html_sidebars configuration if it's not present. It would also be good to be able to configure the default in theme.conf like how html_sidebars works.

@davidism
Copy link
Author

davidism commented Aug 1, 2018

I implemented this using the builder-inited event in an extension. https://github.com/pallets/pallets-sphinx-themes/blob/c9f4461d575dfbc4deb3deaebab89e4ba03c4576/pallets_sphinx_themes/__init__.py#L62-L68

If the builder is an instance of the singlehtml builder and the config is set, it replaces html_config['index'].

I'd have to dig into more Sphinx internals to figure out how this would be implemented natively.

@tk0miya
Copy link
Member

tk0miya commented Aug 4, 2018

Good idea! I just implemented it as #5261.

tk0miya added a commit to tk0miya/sphinx that referenced this issue Aug 4, 2018
@tk0miya tk0miya added this to the 1.8.0 milestone Aug 6, 2018
tk0miya added a commit that referenced this issue Aug 13, 2018
Fix #5246: Add :confval:`singlehtml_sidebars` to configure sidebars for singlehtml
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants