> For the complete documentation index, see [llms.txt](https://docs.rh-webdesign.com/cms-bundle/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rh-webdesign.com/cms-bundle/en/blog/elemente/inhaltsverzeichnis.md).

# Table of contents

Automatically build a table of contents from the post's headings.

The **Table of contents** element automatically builds an index from the post's headings. With one click your readers jump straight to the desired section – especially helpful for long guides and travel reports.

Use Shopware's **element picker** (the **Replace element** button) to add the **Table of contents** element at the desired position – the field outlined in red.

<figure><img src="https://118894700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhdsmo3ttoHQpDlitXnzA%2Fuploads%2Fgit-blob-420af64e59c848834e35433cc9a78063e824dc52%2Fblog-inhaltsverzeichnis-auswahl.webp?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://118894700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhdsmo3ttoHQpDlitXnzA%2Fuploads%2Fgit-blob-fe37acbd1f9e534a5bc409f18ff9581779c85997%2Fblog-inhaltsverzeichnis-beispiel.webp?alt=media" alt=""><figcaption><p>Example in the storefront: automatically generated table of contents</p></figcaption></figure>

### General

Use the **Include** and **Exclude** tabs to control which headings are added to the table of contents.

<figure><img src="https://118894700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhdsmo3ttoHQpDlitXnzA%2Fuploads%2Fgit-blob-f0c6f756f31d06739a057e0678124c6d8c241478%2Fblog-inhaltsverzeichnis-allgemein.webp?alt=media" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="287">Function</th><th>Description</th></tr></thead><tbody><tr><td>Table of contents heading (1)</td><td>Optional title above the index, e.g. "Contents".</td></tr><tr><td>Headings (2)</td><td>On the <strong>Include</strong> tab: which heading levels (H1–H6) are added – namely all headings of that level on the entire page. Empty by default.</td></tr><tr><td>CSS selectors (3)</td><td>For advanced users: additional CSS selectors whose headings are included or (on the <strong>Exclude</strong> tab) excluded. Confirm each selector with Enter. Default: <code>.rhweb-blog-el-content h2</code> and <code>.rhweb-blog-el-content h3</code> – i.e. the H2 and H3 headings in the post text.</td></tr></tbody></table>

#### Server-side output

With the default configuration, the table of contents is delivered together with the page (server-side). This gives you three advantages:

* **No layout shift while loading:** The list is in place right away, nothing moves afterwards (important for the Core Web Vitals metric CLS).
* **Jump links without JavaScript:** The links also work if JavaScript is not loaded.
* **Readable for search engines:** The jump links are part of the HTML code.

IDs you have already assigned to headings in the post text yourself are kept.

Whether the table of contents is generated server-side or by JavaScript depends on the settings on the **General** tab:

<table><thead><tr><th width="287">Setting</th><th>Server-side if …</th></tr></thead><tbody><tr><td>Headings (2)</td><td>… the field is empty.</td></tr><tr><td>CSS selectors (3), <strong>Include</strong> tab</td><td>… only selectors of the form <code>.rhweb-blog-el-content h1</code> to <code>.rhweb-blog-el-content h6</code> are entered (or the field is empty).</td></tr><tr><td>CSS selectors (3), <strong>Exclude</strong> tab</td><td>… the field is empty.</td></tr></tbody></table>

If any of these settings differs, JavaScript builds the list after the page has loaded, as before.

{% hint style="info" %}
Want to include H4 headings from the post text as well? On the **Include** tab, enter the selector `.rhweb-blog-el-content h4` under **CSS selectors** instead of selecting the H4 level in the **Headings** field. This keeps the server-side output.
{% endhint %}

### Responsive - Settings

<figure><img src="https://118894700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhdsmo3ttoHQpDlitXnzA%2Fuploads%2Fgit-blob-474f2a31a87b1382386a8bb75871389c8d26ff5b%2Fblog-inhaltsverzeichnis-responsive.webp?alt=media" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="287">Function</th><th>Description</th></tr></thead><tbody><tr><td>Collapsed on mobile devices (1)</td><td>Below a screen width of 992 px, the list starts collapsed. A button with an arrow expands and collapses it. On desktop, the table of contents stays open as usual. Default: off.</td></tr><tr><td>Set font sizes for different end devices? (2)</td><td>Custom font size of the heading per device, see <a href="https://docs.rh-webdesign.com/cms-bundle/en/elemente/konfigurationsbausteine/schriftgrosse.md">Font size</a>.</td></tr></tbody></table>

#### When is "Collapsed on mobile devices" useful?

If the table of contents sits in a **sidebar**, the sidebar moves above the article on mobile devices. A long index then pushes the actual text far down. Collapsed, the table of contents takes up just one line, and the article starts right below it.

How to enable the option:

1. Under **Content > Shopping Experiences**, open the layout of your post page.
2. Open the settings of the **Table of contents** element (gear icon).
3. Switch to the **Responsive - Settings** tab.
4. Enable **Collapsed on mobile devices** (1).
5. Close the window with **Done** and save the layout.

In the editor, you can tell the option is active by the note below the element (1):

<figure><img src="https://118894700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhdsmo3ttoHQpDlitXnzA%2Fuploads%2Fgit-blob-a241775743123870b3d781a77531688b5a9845f6%2Fblog-inhaltsverzeichnis-hinweis-editor.webp?alt=media" alt="" width="360"><figcaption><p>Note in the shopping experience editor</p></figcaption></figure>

In the storefront, the table of contents initially shows only the **Show table of contents** button on mobile devices (1):

<figure><img src="https://118894700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhdsmo3ttoHQpDlitXnzA%2Fuploads%2Fgit-blob-d89575ac026a1fbb2a931069324b97b66e235bb7%2Fblog-inhaltsverzeichnis-mobil-eingeklappt.webp?alt=media" alt="" width="360"><figcaption><p>Mobile: collapsed – the article starts right below</p></figcaption></figure>

Tapping the button expands the list; the button then reads **Hide table of contents** (1):

<figure><img src="https://118894700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhdsmo3ttoHQpDlitXnzA%2Fuploads%2Fgit-blob-bb84c38244b1446174206095d60ac1adc31ff7f1%2Fblog-inhaltsverzeichnis-mobil-aufgeklappt.webp?alt=media" alt="" width="360"><figcaption><p>Mobile: expanded</p></figcaption></figure>

{% hint style="warning" %}
The option only takes effect with [server-side output](#server-side-output). If JavaScript builds the list (differing selectors), the table of contents stays open on mobile devices as well.
{% endhint %}

### SEO

{% content-ref url="/pages/LHlzFdFr8hVLrftTJKPh" %}
[SEO](https://docs.rh-webdesign.com/cms-bundle/en/elemente/konfigurationsbausteine/seo.md)
{% endcontent-ref %}
