Summary Confusion

I’m either doing something wrong or the way page summaries work is buggy.


  • On my homepage, in a list of pages, show the page summary but truncate it after a number of characters. I need the separate summary because the page content contains images, and truncating the actual content still leaves the first image in.
  • On the page, show only the content, not the summary.

What happens:

  • Using the default summary delimiter “===”, I must have a blank line before and after or it will not work. If it’s up against the text it gets interpreted as a markdown character. But leaving those spaces causes the truncation to not happen: the full summary is shown, not truncated.
  • I tried using a different delimiter “^^^”, which only solved the markdown problem, not the others.
  • On the page itself, the summary shows before the content. I found advice to use a fragile hack:
    {% set content = page.content|slice(page.summary|length) %}
    But the point of a summary is to not be part of the content itself. Shouldn’t the summary not be returned to page.content() in the first place?
  • If I remove the blank lines from around my delimiter, the above hack breaks.

I don’t think the summary functionality is working as expected. Or is there a correct way to handle my case?

i think you have various options.

  1. You could use the regular page summary, but strip out HTML tags (including any images)
  2. You could create a new summary field in your page header, and put a specific summary in there, then on your listing page, just display this new summary field and leave the page content for the page’s display page.
  3. You could use your own delimiter (as you tried) and display the first part on the listing and the other part on the page display page.

Hi @Wartybliggens, I was looking to also only display page content (and not include the summary) and after learning about the slice function it was pretty simple to do (with using the === delimiter).

Here is a little entry about the technique:

And you can see it in action with my Course Hub Bootstrap theme:

Thank you @rhuk and @paulhibbitts.

I know about the slice approach and have used it, but as I said in the “What happens” part of my post, there are issues with that: it breaks (slices incorrectly) if I don’t leave blank lines around the delimiter, and if I do leave blank lines the truncation fails (the entire summary is shown no matter how long).

And let’s take a step back and look at this summary functionality from a distance. As a developer (let alone a less-technical user) I would never expect something called the “summary” to be displayed as part of the page content by default. That it does is quite strange. Who would want such a thing to happen? And having to add code to templates to cut if off feels dirty.

@rhuk - what does this mean:
3. You could use your own delimiter (as you tried) and display the first part on the listing and the other part on the page display page.

With whatever delimiter, the summary is returned as part of the page content. Are you referring to the slice approach?

For your #1, that would also strip out paragraphs, so it doesn’t sound ideal.
For #2, that sounds more promising, and I take it to mean I would need to alter a blueprint, but would the new field then have to be plain text (that is, no markdown / HTML)?

No, it can contain anything you want, even Twig, if you enable Twig processing on the page headers. Just make sure to process the markdown using the Twig filter

Hi all,

Well, quite an old post but - I ran into the same issue while familiarising myself with GRAV. It drove me kind of nuts to see the summary being displayed within the original pages content and not only if extracted via a page collection and {{ p.summary|raw }}

Also, #2 to use a summary field in page header sounds most promising for me - but the downside is, that this is more technical than a regular user would expect (you have to switch from normal to expert mode to do that). But I will give that a try.

Do you have an example if you did it that way? It would be nice not to invent the wheel another time… :wink:

Okay, here is the quite simple solution, based on

  1. open your page and change to expert mode

  2. add to the frontmatter field

    description: My individual summary.
  1. Extract this content e.g. for a page collection and show it via
{% for p in page.collection %}
<h2>{{ p.title|e }}</h2>
{{ p.header.summary.description|raw }}
<a href="{{ p.url|e }}">{{ p.title|e }}</a>
{% endfor %}

To make the custom page header optional, you can add an if statement:

{% for p in page.collection %}
<h2>{{ p.title|e }}</h2>
{% set individual_summary = p.header.summary.description %}
{{ dump(individual_summary) }}
{% if individual_summary==null %}
{{ p.summary|raw }}
{% else %}
<p>{{ p.header.summary.description|raw }}</p>
{% endif %}
<a href="{{ p.url|e }}">{{ p.title|e }}</a>
{% endfor %}

What happens here is, that - if a custom summary is given - this is shown. If not, the regularly build summary is shown as configured within the admin panels
configuration -> site -> page summary



paulhibbitts gave a link a little higher for a little entry about the technique
Displaying page content without summary

After showing a summary can be useful depending on the site / design :upside_down_face: