# New in Hugo 0.132.0: Blockquote render hooks

**URL:** <https://discourse.gohugo.io/t/new-in-hugo-0-132-0-blockquote-render-hooks/51115>\
**Category:** Announcements\
**Created:** [August 12, 2024, 6:15pm UTC](https://discourse.gohugo.io/t/new-in-hugo-0-132-0-blockquote-render-hooks/51115 "2024-08-12T18:15:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [August 12, 2024, 6:15pm UTC](https://discourse.gohugo.io/t/new-in-hugo-0-132-0-blockquote-render-hooks/51115/1 "2024-08-12T18:15:51Z")

</div>

This feature may be overlooked when you read the release notes, so I’m double posting a little:

> **[Blockquote render hooks](https://gohugo.io/render-hooks/blockquotes/)**
>
> Create a blockquote render hook to override the rendering of Markdown blockquotes to HTML.

I know this will be useful for many.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [August 12, 2024, 6:16pm UTC](https://discourse.gohugo.io/t/new-in-hugo-0-132-0-blockquote-render-hooks/51115/2 "2024-08-12T18:16:08Z")

</div>

Pinned globally on August 12, 2024, 6:16pm UTC



---

<div class="post-metadata">

**Author:** ![jzeneto](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jzeneto/32/9539_2.png) [@jzeneto](https://discourse.gohugo.io/u/jzeneto)\
**Post date:** [August 13, 2024, 5:39am UTC](https://discourse.gohugo.io/t/new-in-hugo-0-132-0-blockquote-render-hooks/51115/3 "2024-08-13T05:39:14Z")

</div>

It is indeed very nice! But I didn’t understand the `Ordinal` context’s field:

- is it the blockquote’s level (in case of blockquotes inside blockquotes) or
- is it the current number of times the render hook was called in the current page?

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [August 13, 2024, 8:51am UTC](https://discourse.gohugo.io/t/new-in-hugo-0-132-0-blockquote-render-hooks/51115/4 "2024-08-13T08:51:24Z")

</div>

> [@jzeneto](#):
>
> is it the current number of times the render hook was called in the current page?

That’s it.

---

<div class="post-metadata">

**Author:** ![Tom\_Durand](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom_durand/32/14460_2.png) [@Tom\_Durand](https://discourse.gohugo.io/u/Tom_Durand)\
**Post date:** [August 13, 2024, 10:24am UTC](https://discourse.gohugo.io/t/new-in-hugo-0-132-0-blockquote-render-hooks/51115/5 "2024-08-13T10:24:44Z")

</div>

And I don’t understand the Position attribute. How would you use it ?

For now I get all sorts of errors that I didn’t get when using codeblock. See the following:

```auto
{{ $class := .Attributes.class }}
{{ $cite := .Page.RenderString .Attributes.cite }}
<figure {{with .Attributes.id}}id="{{.}}" {{end}} {{with $class}}class="{{.}}"{{end}}>{{with $title}}<figcaption>{{.}}</figcaption>{{end}}
<blockquote {{if in $cite "]("}}cite="{{strings.TrimSuffix ")" (index (last 1 (split $cite "](")) 0)}}"{{end}}>{{ .Text|.Page.RenderString (dict "display" "block") }}</blockquote>
<cite>{{with $cite}}{{.}}{{end}}{{with $author}} — {{.}}{{end}}</cite>
</figure>

```

it raises

> ERROR render of “page” failed: “/home/drm/NNSITE/layouts/\_default/baseof.html:27:4”: execute of template failed: template: \_default/single.html:27:4: executing “specific-content” at \<.Content\>: error calling Content: “/home/drm/NNSITE/content/docs/ecotech.md:29:3”: “/home/drm/NNSITE/layouts/\_default/\_markup/render-blockquote.html:8:121”: execute of template failed: template: \_default/\_markup/render-blockquote.html:8:121: executing “\_default/\_markup/render-blockquote.html” at \<$.Page.RenderString\>: error calling RenderString: text is already rendered, repeating it may cause infinite recursion

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [August 13, 2024, 10:46am UTC](https://discourse.gohugo.io/t/new-in-hugo-0-132-0-blockquote-render-hooks/51115/6 "2024-08-13T10:46:20Z")

</div>

> [@Tom\_Durand](#):
>
> And I don’t understand the Position attribute. How would you use it ?

You should (or so say I) only use it for error logging, mainly because it’s relatively slow to compute.

See this example:

> **[transform.ToMath](https://gohugo.io/functions/transform/tomath/#error-handling)**
>
> Renders a math expression using KaTeX.

It’s very useful for custom validation, as it will log the filename and position (line/col number) where the blockquote is; if you use an editor like VS code with built-in terminal, you can just command click on the position and it will take you there.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [August 13, 2024, 11:05am UTC](https://discourse.gohugo.io/t/new-in-hugo-0-132-0-blockquote-render-hooks/51115/7 "2024-08-13T11:05:17Z")

</div>

> [@Tom\_Durand](#):
>
> For now I get all sorts of errors that I didn’t get when using codeblock. See the following:
> 
> ```auto
> 
> ```

> $.Page.RenderString\>: error calling RenderString: text is already rendered

The `Text` attribute in a blockquote render hook is HTML, and it does not make sense to render it again (it was a common cause of infinite recursion before we added the validation you see above).

Codeblocks are different; the `.Inner` is the _raw_ text, so to speak, which may make sense to pass to RenderString (but more common is to highlight it).

---

<div class="post-metadata">

**Author:** ![Tom\_Durand](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom_durand/32/14460_2.png) [@Tom\_Durand](https://discourse.gohugo.io/u/Tom_Durand)\
**Post date:** [August 13, 2024, 11:51am UTC](https://discourse.gohugo.io/t/new-in-hugo-0-132-0-blockquote-render-hooks/51115/8 "2024-08-13T11:51:41Z")

</div>

Ahhh… Makes sense. Great addition !
