# Get the content without the summary

**URL:** <https://zola.discourse.group/t/get-the-content-without-the-summary/922>\
**Category:** Support\
**Created:** [May 27, 2021, 8:35am UTC](https://zola.discourse.group/t/get-the-content-without-the-summary/922 "2021-05-27T08:35:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eike](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/eike/32/523_2.png) [@eike](https://zola.discourse.group/u/eike)\
**Post date:** [May 27, 2021, 8:35am UTC](https://zola.discourse.group/t/get-the-content-without-the-summary/922/1 "2021-05-27T08:35:05Z")

</div>

On my site, I sometimes want to use tables of content. However, I would prefer to include them after the first paragraph (similar to how Wikipedia does it). My idea is to use the break created by adding a summary (with `<!-- more -->`), i.e. put the summary on top, then the table of contents, then the rest of the content. For this, I would need a page variable containing only the rest of the content, so the summary doesn’t repeat (and preferably without the auto-generated `continue-reading` span, as I can add that myself in this case). Does something like this exist? Or is there another way of injecting a table of contents into the middle of my post?

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [May 27, 2021, 9:25am UTC](https://zola.discourse.group/t/get-the-content-without-the-summary/922/2 "2021-05-27T09:25:17Z")

</div>

There’s no way to do that right now in zola, but that would be easy to do in JS

---

<div class="post-metadata">

**Author:** ![piegames](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/piegames/32/893_2.png) [@piegames](https://zola.discourse.group/u/piegames)\
**Post date:** [March 22, 2024, 1:31pm UTC](https://zola.discourse.group/t/get-the-content-without-the-summary/922/3 "2024-03-22T13:31:51Z")

</div>

I’d like to second this, as a feature request. This should be pretty straightforward to code and not require JavaScript.

---

<div class="post-metadata">

**Author:** ![piegames](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/piegames/32/893_2.png) [@piegames](https://zola.discourse.group/u/piegames)\
**Post date:** [March 22, 2024, 8:14pm UTC](https://zola.discourse.group/t/get-the-content-without-the-summary/922/4 "2024-03-22T20:14:28Z")

</div>

Okay, I’ve found two workarounds: The first one is to use

```plaintext
    {{ page.summary | default(value="") | safe }}
    <!-- toc here -->
    {{ page.content | replace(from = page.summary | default(value=""), to= "") | safe }}

```

the downside of this is that the `replace` function replaces _all_ occurrences, which feels a bit weird (but also that’s an issue with Tera default functions tbh).

An alternative way is to use `split`:

```plaintext
    {% set content = page.content | split(pat="<!-- TOC -->") %}
    {% if content | length > 1 %}
    {{ content[0] | safe }}
    {% endif %}

    <!-- TOC here -->

    {% if content | length > 1 %}
    {{ content[1] | safe }}
    {% else %}
    {{ content[0] | safe }}
    {% endif %}

```

This one puts the TOC where you write `<!-- TOC -->`. The advantage is that this is not bound to the “summary” feature anymore, and you can better customize where to put it. I agree that the code is a bit less elegant, though it would have a rather pretty solution if I could store templated blocks into their own variable. Still need to figure that out.
