Skip to content

Commit 5b417ad

Browse files
gabalafoutrallard
andauthored
Fix landmark-unique error due to in-page TOC (#1607)
* landmark unique error due to in-page TOC * Apply suggestions from code review Co-authored-by: Tania Allard <[email protected]> * fix lint? --------- Co-authored-by: Tania Allard <[email protected]>
1 parent 3de3059 commit 5b417ad

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

docs/examples/in-page-toc.rst

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
:html_theme.sidebar_secondary.remove: true
2+
3+
Test of in-page TOC with no right sidebar
4+
=========================================
5+
6+
This page tests that the local contents directive looks okay.
7+
8+
.. attention::
9+
10+
We **do not recommend** using this directive on pages that use this theme
11+
because PyData Theme provides an in-page table of contents in the right sidebar
12+
by default.
13+
14+
If you do choose to use an inline, in-page table of contents, we recommend that
15+
you turn off the right sidebar as follows.
16+
17+
.. contents:: Page contents
18+
:local:
19+
20+
21+
Add a local table of contents (in-page)
22+
---------------------------------------
23+
24+
Add the local table of contents directive near the top of your ``.rst`` page:
25+
26+
.. code-block:: rst
27+
28+
.. contents:: Page contents
29+
:local:
30+
31+
This directive will generate a table of contents for the section where this was
32+
added, as shown on this page.
33+
34+
35+
Turn off the right sidebar for a single page
36+
--------------------------------------------
37+
38+
On the very top line of your ``.rst`` file, insert the following line:
39+
40+
.. code-block:: rst
41+
42+
:html_theme.sidebar_secondary.remove: true
43+
44+
This will render the page without the right sidebar, also known as the secondary
45+
sidebar, which contains the table of contents for that page.
46+
47+
Be aware that if you remove the sidebar you may also remove the "Edit on ..."
48+
and "Show source" links for that page, since by default those are configured for
49+
the right sidebar.

docs/examples/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ See the sections in the primary sidebar and below to explore.
2929

3030
no-sidebar
3131
persistent-search-field
32+
in-page-toc
3233
subpages/index
3334
mult_headers
3435
Link to an external site <https://jupyterbook.org/>

docs/user_guide/theme-elements.md

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
There are a few elements that are unique or particularly important to this theme.
44
Some of these are triggered with configuration or Markdown syntax that is unique to the theme, and we cover them below.
55

6-
```{contents} Page contents
7-
:local:
8-
```
9-
106
## Mathematics
117

128
Most Sphinx sites support math, but it is particularly important for scientific computing, so we illustrate support here as well.

0 commit comments

Comments
 (0)