# Hugo post summary

**URL:** https://discourse.gohugo.io/t/hugo-post-summary/20698
**Category:** support
**Created:** [September 10, 2019, 2:28pm UTC](https://discourse.gohugo.io/t/hugo-post-summary/20698 "2019-09-10T14:28:10Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Ilya\_Nemtsev](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ilya_nemtsev/32/8470_2.png) [@Ilya\_Nemtsev](https://discourse.gohugo.io/u/Ilya_Nemtsev)
#### Post date: [September 10, 2019, 2:28pm UTC](https://discourse.gohugo.io/t/hugo-post-summary/20698/1 "2019-09-10T14:28:10Z")

</div>

Hi friends,

I am trying to customize the summary that is displayed for my blog posts. It keeps using the first `some number` of characters. But, I want to use an image or some small html instead. I tried putting html inside `summary: "..."` in the article front matter, but this did nothing.

Any suggestions?  
Leo

---

<div class="post-metadata">

### Author: ![bmackinney](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bmackinney/32/2202_2.png) [@bmackinney](https://discourse.gohugo.io/u/bmackinney)
#### Post date: [September 10, 2019, 3:31pm UTC](https://discourse.gohugo.io/t/hugo-post-summary/20698/2 "2019-09-10T15:31:12Z")

</div>

@Ilya_Nemtsev content summaries are automatically generated and accessed through the page .Summary variable. See [https://gohugo.io/content-management/summaries/](https://gohugo.io/content-management/summaries/).  
{{ .Summary | safeHTML }} should do the trick. no summary frontmatter is necessary.

---

<div class="post-metadata">

### Author: ![Ilya\_Nemtsev](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ilya_nemtsev/32/8470_2.png) [@Ilya\_Nemtsev](https://discourse.gohugo.io/u/Ilya_Nemtsev)
#### Post date: [September 10, 2019, 4:44pm UTC](https://discourse.gohugo.io/t/hugo-post-summary/20698/3 "2019-09-10T16:44:19Z")

</div>

I updated my template and that did the trick!  
Thank you @bmackinney

---

<div class="post-metadata">

### Author: ![ju52](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ju52/32/6749_2.png) [@ju52](https://discourse.gohugo.io/u/ju52)
#### Post date: [September 10, 2019, 6:00pm UTC](https://discourse.gohugo.io/t/hugo-post-summary/20698/4 "2019-09-10T18:00:16Z")

</div>

I use sometimes

`<p>{{ .Summary | plainify | chomp }}</p>`

bc .Summary breaks HTML elements (some time ago - not tested again)

---

<div class="post-metadata">

### Author: ![patdavid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/patdavid/32/9203_2.png) [@patdavid](https://discourse.gohugo.io/u/patdavid)
#### Post date: [September 20, 2019, 9:28pm UTC](https://discourse.gohugo.io/t/hugo-post-summary/20698/5 "2019-09-20T21:28:13Z")

</div>

I’ve tried this but am still having some issues (sorry to post here - if I’m hijacking this thread please feel free to break out my post to a new topic).

If I use the automatically generated `{{ .Summary }}` all of the HTML is stripped from the output.

Is there any way to retain the HTML associated with the file being summarised?

For example, with a post markdown file with content like this at the beginning:

```auto
## First header

This is a first sentence _for example_.

This is a second sentence, new paragraph.

```

If I use the automatic `{{ .Summary }}` for this page, it renders as:

```auto
First header This is a first sentence for example. This is a second sentence, new paragraph.

```

(note: this also happens with `{{ .Summary | safeHTML }}`.

What I would expect to render is the HTML also:

```auto
<h2>First header</h2>
<p>This is a first sentence for example.</p>
<p>This is a second sentence, new paragraph.</p>

```

As a small work-around I’m using: `{{ .Content | safeHTML | truncate 500 }}`.  
Where I truncate the full post by N characters (but this is not as nice as the autosummary - sometimes the break is in the middle of a sentence with ellipses).

related:  
[https://discourse.gohugo.io/t/summary-strips-all-html-tags-regardless-of-length/2151](https://discourse.gohugo.io/t/summary-strips-all-html-tags-regardless-of-length/2151)

---

<div class="post-metadata">

### Author: ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)
#### Post date: [September 20, 2019, 11:37pm UTC](https://discourse.gohugo.io/t/hugo-post-summary/20698/6 "2019-09-20T23:37:17Z")

</div>


